I am working with two 2D arrays, actually:
MatrixAddition(int[][] a, int[][] b)
Adding two matrix using LINQ and returning them to 2D array format int[][]. LINQ result is ok, returned expected result, but can't helping myself to return them in int[][] format.
MatrixAddition()
public static int[][] MatrixAddition(int[][] a, int[][] b)
{
return (int[][])a.Select((x, i) => x.Select((y, j) => a[i][j] + b[i][j]));
}
Error: System.InvalidCastException: 'Unable to cast object of type 'd__52[System.Int32[],System.Collections.Generic.IEnumerable1[System.Int32]]' to type 'System.Int32[][]'.'