LINQ extention SelectMany in 3.5 vs 4.0?

Posted by Moberg on Stack Overflow See other posts from Stack Overflow or by Moberg
Published on 2010-06-17T17:14:10Z Indexed on 2010/06/17 17:53 UTC
Read the original article Hit count: 224

Filed under:
|
|

Hi

When I saw Darins suggestion here ..

IEnumerable<Process> processes = 
    new[] { "process1", "process2" } 
    .SelectMany(Process.GetProcessesByName);

( http://stackoverflow.com/questions/3059667/process-getprocessesbyname/3059733#3059733 )

.. I was a bit intrigued and I tried it in VS2008 with .NET 3.5 - and it did not compiling unless I changed it to ..

IEnumerable<Process> res = 
  new string[] { "notepad", "firefox", "outlook" }
    .SelectMany(s => Process.GetProcessesByName(s));

Having read some Darins answers before I suspected that it was me that were the problem, and when I later got my hands on a VS2010 with.NET 4.0 - as expected - the original suggestion worked beautifully.

My question is : What have happend from 3.5 to 4.0 that makes this (new syntax) possible? Is it the extentionmethods that have been extended(hmm) or new rules for lambda syntax or? I've tried to search but my google-fu was not strong enough.

Please forgive if the question is a bit naive and note that I've taged it as beginner :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about beginner