KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Say I have a simple array: double[] myDoubleArray = new double[] { 0, 1, 2, 3, 4, 5 }; Is this as performant: double last = myDoubleArray.Last(); as this? double last = myDoubleArray[myDoubleArray.Length - 1]; Will Last() enumerate over the entire array even when it can make the above optimization? If I passed some other IEnumerable (say one that was yielded), Last() would have to enumerate the sequence. I prefer using Last(), because code looks cleaner, but I would not make a sacrifice if it enumerates the sequence.
Tags (comma-separated)
Save Edits
Cancel