C
Chris Dunaway
I understand, basically, what this C# 3.0 code does, but I am unclear
on how it determines the data type of num and index in the lambda
expression in the following code. Nor can I see how it gets the array
index into the index parameter?
BTW: Is there a better forum for asking these questions?
public void Linq12() {
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var numsInPlace = numbers.Select((num, index) => new {Num = num,
InPlace = (num == index)});
Console.WriteLine("Number: In-place?");
foreach (var n in numsInPlace) {
Console.WriteLine("{0}: {1}", n.Num, n.InPlace);
}
}
on how it determines the data type of num and index in the lambda
expression in the following code. Nor can I see how it gets the array
index into the index parameter?
BTW: Is there a better forum for asking these questions?
public void Linq12() {
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var numsInPlace = numbers.Select((num, index) => new {Num = num,
InPlace = (num == index)});
Console.WriteLine("Number: In-place?");
foreach (var n in numsInPlace) {
Console.WriteLine("{0}: {1}", n.Num, n.InPlace);
}
}