Click here to Skip to main content
15,900,254 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to implement Generics for my ObjectCollection class.

Is there any way that I would be able to use both List<t> and ICollection<t> in my ObjectCollection class.

Actually Icollection Provide me only Add,Insert,Remove... some functions which I can override for my custom Implementation. I want to use some more fetures from List<t> like sort...

basically I want that it let me use the functionality of both the interfaces.we know that we can write our own custom function to sort the objects in the Icollection but I know the List gives better performace than ICollection so I want to use the both the features.

I am a little confused here.

I will appreaciate for your immed. help!!!
Posted

Well IList<T> will give you ICollection<T> anyway so use that. For Sort use IComparable<T> as well.
C#
public class MyCollection<T> : IList<T>, IComparable<T>
{
    // ...
}

or
C#
public class MyObject
{
    // ...
}
public class MyObjectCollection : IList<MyObject>, IComparable<MyObject>
{
    // ...
}
 
Share this answer
 
v3
Comments
rajeshswami27 1-Jun-10 2:55am    
Thanks a lot DaveyM69
it's fine
could you please give me an example of handling the Ilist between Tiers.

Business Layar
Data access layer
Have you looked at System.Collections.Generic.IList<T>

It implements ICollection<T>, IEnumerable<T> and IEnumerable.

It also has many, many methods such as OrderBy, ToList<T>, ToDictionary<T, TKey> etc.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900