How extension methods work in background ?

Posted by Freshblood on Stack Overflow See other posts from Stack Overflow or by Freshblood
Published on 2010-06-08T09:30:41Z Indexed on 2010/06/08 9:32 UTC
Read the original article Hit count: 258

Filed under:
|
|
|
|

I am just cuirous about behind of extension method mechanism.Some questions and answer appear in my mind.

MyClass.OrderBy(x=>x.a).OrderBy(x=>x.b);

I was guessing that mechanism was first orderby method works and order them by a member then returns sorted items in IEnumarable interface then next Orderby method of IEnumarable Order them for b paramater.But i am wrong when i look at this linq query.

MyClass.Orderby(x=>x.a).ThenOrderBy(x=>x.b);

this is slightly different and tells me that i am wrong.Because this is not ordering by a then b and not possible to have such result if i was right.This get me confuse enough...

Similiar structure is possible to write withot extension methods as first query but second is not possible.This prove i am wrong . Can u explain it ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET