Sorry if not describing clear below because I'm new to C#. I want to do the task that add up all the numbers in the int[]
listed below that fetched out via LINQ, and converted into long
. the var Sum
works good by using lambda operator, but I want to rewrite in an old-school way - don't use any lambda and anonymous functions in Sum2
. Can someone show an example of how to write it?
private static void main(string[] args)
{
int[] numbers = RandomN(55555);//generate new int[55555]
var result =
from n in numbers
where n >= 1000
select n;
long Sum = result.Sum(j=>(long)j);
long Sum2 = result.Sum(???);
}
private int[] randomN(int j){...}