Created
February 16, 2013 01:41
-
-
Save dlhartveld/4965058 to your computer and use it in GitHub Desktop.
A simple example of a LINQ query over a collection of objects (strings, in this case). helloLength1 and helloLenght2 are equivalent - the compiler just desugars the LINQ expression to the same AST that the second expression results in.
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
List<string> ss = new List<string>(); | |
ss.Add("Hello"); | |
ss.Add("World"); | |
var helloLength1 = from s in ss | |
where s.StartsWith("H") | |
select s.Length; | |
var helloLength2 = ss.Where(s => s.StartsWith("H")).Select(s => s.Length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment