I read Jon Skeet C # In Depth: Second Edition , and I noticed something a little different in one of his examples from what I do myself.
It has something similar to the following:
var item = someObject.Where(user => user.Id == Id).Single();
While I was doing the following:
var item = someObject.Single(user => user.Id == Id);
Is there any real difference between the two? I know that John Skeet is pretty much a C # god, so I tend to think that his knowledge in this area is better than mine, so I might not understand something. Hope someone can help.
, ( IE L2S).
, " ". , Count, . Any :)
Count
Any
- - , . , , .. - , P499.
" " , .
, , , IL, Where, , , ( LinqPAD).
IL_0042: call System.Linq.Enumerable.Where IL_0047: call System.Linq.Enumerable.Single
System.Linq.Enumerable.Single
IL_006B: call System.Linq.Enumerable.Single
, Linq2Objects, Enumerable.Single(this, predicate) , , Enumerable.Where , Enumerable.Single .
Enumerable.Single(this, predicate)
Enumerable.Where
Enumerable.Single
Enumerable.Single , . , , , ? , , , .