TakeAllButLast

[UPDATE: Newer TakeAllButLast!]
Linq provides us with the extension method First() to get the first item in an enumerable. It also gives us Take(x) to get the first x items. The provided Last() extension method has no “TakeAllButLast(x)” equivalent.

I wanted one, so I wrote it (with a conceptual tip provided by a coworker). It’s not trivial to do if you want to make sure that you only enumerate the list once.

Related

3 responses to “TakeAllButLast”

Howdy would you mind letting me know which hosting
company you’re using? I’ve loaded your blog in 3 completely different browsers and I must
say this blog loads a lot faster then most. Can you recommend a good web hosting provider at
a fair price? Thanks a lot, I appreciate it!