Not the most important question in the world but as a soon graduate I figured I would like to have this knowledge going forward. Having said that, how does LINQ find the data I need based on the conditions I provide behind the scenes?
Consider:
String[] straAr = {"Jordan","Jansyn","Corey","Josh","Whitney"};
var sel = from S in straAr
where S.Contains("syn")
select S;
This will, of course, result in "Jansyn". Before I was introduced to LINQ, I would have done this:
String[] straAr = {"Jordan","Jansyn","Corey","Josh","Whitney"};
foreach(String s in straAr)
{
if(s.Contains("syn"))
{
Console.WriteLine(s);
}
}
They both work, though I think LINQs implementation is much more elegant. Can anyone tell me:
How does LINQ query a data structure behind the scenes? Foreach?
Is one implementation more efficient than the other?
As always, thanks for any input!