Interfaces
IEnumerable<T>
ICollection<T>
IList<T>
Concrete Implementations
List<T>
List<T>
Other collections of interest are- SortedList<T>
There is no SortedList<T>
Combining these collections with LINQ provides a lot of cool possibililities for every day scenarios . LINQ requires the object to implement IEnumerable or IQueryable interface.
The best part is that these new generic classes and interfaces are compatible with the old non-generic ones.
public class List
IList
This means if existing methods uses old interfaces as parmaeter, you still can supply the generic ones.
If you are planning to change all your existing non-generic types in your project to the generic one to improve performance and type safety make sure the generic ones has all the properties and methods available. In most case it may not be a one-to-one mapping.
No comments:
Post a Comment