// Overload Subtract public static Matrix operator -(Matrix One, Matrix Two) { Matrix Result = new Matrix( // New Matrix Math.Min( // Rows One.GetLength(0), // Equal to the Two.GetLength(0)), // Smaller of the two Math.Min( // Columns One.GetLength(1), // equal to the Two.GetLength(1))); // smaller of the two for (int row = 0; row < Math.Min( // for each row One.GetLength(0), // up to the row count Two.GetLength(0)); row++) // of the smaller matrix { for (int col = 0; col < Math.Min( // for each col One.GetLength(1), // up to the col count Two.GetLength(1)); col++) // of the smaller matrix { Result[row, col] = One[row, col] - Two[row, col]; } } return(Result); }