Last post Oct 27, 2015 07:53 AM by Mukesh_Kumar
Oct 27, 2015 04:28 AM|n.m.rameshraja|LINK
Please help on this..
Oct 27, 2015 06:01 AM|Nan Yu|LINK
When to use IEnumerable, ICollection, IList and List?
I would suggest you could refer to below article which provide detail explanation and demo about your question:
Oct 27, 2015 07:53 AM|Mukesh_Kumar|LINK
IEnumerable is suitable just for iterate through collection and you can not modify (Add or Remove) data IEnumerable bring ALL data from server to client then filter them, assume that you have a lot of records so IEnumerable puts overhead on your memory.
ICollection inherits from IEnumerable. you can find IEnumerable[ i ] Index Based andyou can NOT find ICollection[ i ] Not Index Based
IList is an interface and implements methods. Whenever you estimate probability that your code would be changed in future you have to use IList because interface reduces dependency and with the little modification your code runs. Therefore you should observe
polymorphism in order to decouple your app and control on adding or removing method that might be changed. Everything else is similar. Whenever we want to change on some operation, so “IList” allow us to do that easily with at least changing in the whole of
List is NOT Fixed Length -> It is possible that data grows. On the one hand it is a good feature whenever developers are not sure about size of arraylist and on the other hand it might take long time for size definition.
List is Strongly Typed when it is defined "Generic" -> Whenever developers are sure about what is exactly type definition for input or output data and they do not wait until runtime to appear its type. This feature makes to run fast at runtime, since it
does not need to wait for type definition.
Hope this will help you.