c# - When can IEnumerable not be converted to IList? -
i found code in project i'm working on:
ienumerable<int> foo = ienumerableintvariable ilist<int> ?? ienumerableintvariable.tolist();
i know as
returns null if can't convert, , tolist()
kick in finish job, situations in happen?
among others, consider simple case:
public ienumerable<int> getlistofnumbers() { (int = 0; < 100; i++) yield return i; }
this returns true ienumerable
wouldn't implement ilist
(msdn). clearly, adding/removing "collection" doesn't make sense, nor elements accessible via index.
Comments
Post a Comment