Consider the following code:
static IEnumerable<int> GetItems()
{
return Enumerable.Range(1, 10000000).ToArray(); // or: .ToList();
}
static void Main()
{
int count = GetItems().Count();
}
Will it iterate over all the 10 billion integers and count them one-by-one, or will it use the array's Length
/ list's Count
properties?