A
AA2e72E
At this site: http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx
The example : First - Indexed
This sample prints the elements of an integer array that are both even and
at an even index within the array. It uses First with an index parameter to
find the desired numbers.
public void Linq60() {
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int evenNum = numbers.First((num, index) => (num % 2 == 0) && (index % 2
== 0));
Console.WriteLine("{0} is an even number at an even position within the
list.", evenNum);
}
The line int evenNum = numbers.First((num, index) => (num % 2 == 0) &&
(index % 2 == 0));
Creates an error : Delegate 'System.Func<int,bool>' does not take '2'
arguments
How can I alter the offending line (still using LINQ) to reproduce the
result shown?
PS: !!! I don't understand the point of publishing samples that do NOT work-
there are several others like this at the site !!!
The example : First - Indexed
This sample prints the elements of an integer array that are both even and
at an even index within the array. It uses First with an index parameter to
find the desired numbers.
public void Linq60() {
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int evenNum = numbers.First((num, index) => (num % 2 == 0) && (index % 2
== 0));
Console.WriteLine("{0} is an even number at an even position within the
list.", evenNum);
}
The line int evenNum = numbers.First((num, index) => (num % 2 == 0) &&
(index % 2 == 0));
Creates an error : Delegate 'System.Func<int,bool>' does not take '2'
arguments
How can I alter the offending line (still using LINQ) to reproduce the
result shown?
PS: !!! I don't understand the point of publishing samples that do NOT work-
there are several others like this at the site !!!