Question

I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"?

var selectVar = arrayVar.Select( (a,i) => new { Line = a });

var selectVar =
    from s in arrayVar 
    select new { Line = s };
Was it helpful?

Solution

OTHER TIPS

the first isn't even really linq, its a lambda expression, with a type invariant object created. (a) => new { blah = b}

The second is a linq query filling an on the fly class that has a property Line. There is no hashrocket operator in this one, so this one is just plain old linq.

The name of the second form is "query comprehesion syntax", which the compiler translates into the first form.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top