Possible Duplicate:
C# - List<T> or IList<T>
I'm working on a solution have noticed there is a lot fo IList being implemented. Just wondering, what is the point of using an IList when you can use a List?
Possible Duplicate:
C# - List<T> or IList<T>
I'm working on a solution have noticed there is a lot fo IList being implemented. Just wondering, what is the point of using an IList when you can use a List?
Because some collections may inherit from IList and not from List, ObservableCollection for example.
If you want don't want to inherit List and just want to implement the interface use IList.
Perhaps you want to return an object that supports IList but the implementation is irrelavant to the caller?
In your case implementing IList may result in unesscessary typing, it may be right thing to do, I' can't know without more info.
You should always try to use the interface where possible to allow the user to have more flexibility on which implementation they use. Generally, IEnumerable and IQueryable are even better than IList as they're more generic, unless you want to limit this with good reason of course.