> Does anybody have a work round to using Indexers in Generics,
> I have a custom class like this:
>
> public class FileCollection<T> : List<T> { }
>
> I would like to create my own indexer but cannot using
> Generics.  Am I alone in thinking this is a very limited
> feature to not have Indexers in Generics or we cannot have
> Generic Properties.
>
> Am I missing the point with Generics??Thanks

        It might be helpful to explain why you can't use generics. I mean, 
what's wrong with the indexer of List<T> ?

        If you can't use generics, you can do:
public interface IFileCollection
{
        object this [int index] {get; set;}
}


then in FileCollection<T> :

public FileCollection<T> : List<T>, IFileCollection
{

        //..

        // implement IFileCollection explicitly
        object IFileCollection.this[int index]
        {
                get
                {
                        return this[index];
                }
                set
                {
                        this[index] = (T)value;
                }
        }
}

                Frans

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to