Please note: If you find any post DOES NOT contain required amount of explanation, please do comment them with a request for more information. I will update as soon as I can attend to it. Also you can contact me with a link to the post.


Tuesday, November 13, 2007

Overriding Index of a Generic List

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace Application.DomainModel.Collections
{
    public class Couriers<Courier> : List<Courier>
    {
        public Courier this[string courierCode]
        {
            get
            {
                return this.Find(delegate(Courier courier)
                { return (string.Compare(courier.CourierCode, courierCode) == 0); });
            }
        }
    }
    public class Courier
    {
        public string CourierCode { getset; }
    }
}
 

Copyrights(C) - Charith Gunasekara 2005-2010