I've just read this question: Convert string[] to int[] in one line of code using LINQ
There was an array of strings:
var arr = new string[] { "1", "2", "3", "4" };
And one of the accepted answers was:
int[] myInts = arr.Select(int.Parse).ToArray();
I tried it myself and received a cs04011 compiler error:
string str = "4 8 15 16 23 42";
int[] intArray = str.Split(' ').Select(int.Parse).ToArray();
Here's page, describing this compiler error: MSDN
If I do it this way, it works fine:
int[] intArray = str.Split(' ').Select(p=>int.Parse(p)).ToArray();
I'm wondering, why did the accepted asnwer for the previous question worked fine and I get an error?
My guess is that my visual studio (2008 express, targeted framework = 3.5) is no good, but I failed to find any proofs.
Thanks in advance!