Dotted linq - which is better, or what's the difference between the two?

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.

+5
source share
4 answers

, ( IE L2S).

+6

, " ". , Count, . Any :)

- - , . , , .. - , P499.

" " , .

+3

, , , 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
+1

, Linq2Objects, Enumerable.Single(this, predicate) , , Enumerable.Where , Enumerable.Single .

Enumerable.Single , . , , , ? , , , .

+1
source

All Articles