# Convert Matrix .NET

Hello.

Task. Given a matrix: size `[m,m]` , create a new matrix in which the k-th row and the n-th column are cut (n and k are specified by the user), respectively, the size of the new matrix `[(m-1),(m-1)]` . Here is my code

` `private static void CreateMatrix(int[,] ints, int value, int k, int n) { int lengthResult = value - 1; int tempColum = 0; int limitColum = n - 1; int limitLine = k - 1; var massiveResult = new int[lengthResult, lengthResult]; for (int colum = 0; colum < value; colum++) { if (colum != limitColum) { int tempLine = 0; for (int line = 0; line < value; line++) { if (line == limitLine) { if (limitLine != lengthResult) { massiveResult[tempColum, tempLine] = ints[colum, ++line]; } } else { massiveResult[tempColum, tempLine] = ints[colum, line]; } tempLine++; } tempColum++; } } DisplayArrayOf(massiveResult, lengthResult); }` `

He is a worker, but the question is how to optimize it or solve a problem in another way is not so trivial?

` `int m = 5; var matrix = new int[,]{{10,11,12,13,14}, {20,21,22,23,24}, {30,31,32,33,34}, {40,41,42,43,44}, {50,51,52,53,54}}; int k=1, n=3; Enumerable.Range(0,m) .Select(el=>Enumerable.Range(0,m) .Where(elem=>elem!=n)) // Удаляем столбец .Select((el,i)=>el.Select(j=>matrix[i,j])) .Where((el,i)=>i!=k) // Удаляем строку` `