KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Let's say I have a sequence. IEnumerable<int> sequence = GetSequenceFromExpensiveSource(); // sequence now contains: 0,1,2,3,...,999999,1000000 Getting the sequence is not cheap and is dynamically generated, and I want to iterate through it once only. I want to get 0 - 999999 (i.e. everything but the last element) I recognize that I could do something like: sequence.Take(sequence.Count() - 1); but that results in two enumerations over the big sequence. Is there a LINQ construct that lets me do: sequence.TakeAllButTheLastElement();
Tags (comma-separated)
Save Edits
Cancel