Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created June 28, 2013 08:54
Show Gist options
  • Save AlexArchive/5883416 to your computer and use it in GitHub Desktop.
Save AlexArchive/5883416 to your computer and use it in GitHub Desktop.
LINQ Compilation
//data source
string[] names = { "ByteBlast", "Shockwave2", "Salmoneus", "Banksy" };
//query syntax
var names1 =
from name in names
where name.StartsWith("B")
select name;
//compiler translates the above into :-
var names2 =
names.Where(name => name.StartsWith("B"))
.Select(name => name);
//the select is actually known as a "degenerate select"
//the compiler removes it too :-
var names3 =
names.Where(name => name.StartsWith("B"));
//in turn, names3 is converted to :-
var names4 =
Enumerable.Where(names, name => name.StartsWith("B"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment