Saturday, August 30, 2014

IEnumerable Syntactic Sugar Proposal

What I really want to know is, what is the difference between:

public static IEnumerable<int> GetNumber()
{
return _numbers.Select(x => x);
}

and



public static IEnumerable<int> GetNumber()
{
return _numbers;
}


In the first example you return the items lazily whereas in the second you just return the array as is with an implicit cast to IEnumerable<int>.



Cheers,


Eyal Shilony


You are free to contact me through 'msdn at shilony net' for anything related to the C# forum.


No comments:

Post a Comment