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

Popular posts from this blog

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -