Using the LINQ Keyword "First"
●
Permalink
●
suggest edit
All day I was stumped on why there wasn’t a simple way to grab the first object in a sequence other than using:
1
.Take(1).Single
Then I discovered the keyword First. I’m still a little puzzled as to why .Single would throw an exception if more than a single element would be returned. I can’t really see a practical use for it unless you wanted to force only 1 object being returned.