Created
June 28, 2013 08:54
-
-
Save AlexArchive/5883416 to your computer and use it in GitHub Desktop.
LINQ Compilation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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