I am trying to return the sum of the elements of a 2 dimensional array from my DLL, but can't seem to get it to work correctly. The returning integer which should be the 'sum' of the array elements returns a null. Could use some advice...
int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
Class1.arraySum(array2D);
Console.WriteLine("Sum of 2D Array of numbers ({ 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 })\n");
Console.WriteLine(sum);
DLL
public static int arraySum(int[,] values)
{
int sum = values.Cast<int>().Sum();
return sum;
}