How can I delete rows and columns from 2D array in C#? -


How to delete a specific row and column from the 2D array in C #?

  int [,] array = {{1,2,3}, {4,5,6}, {7,8,9}}; I say that I want to delete the line I and the column i (except them) ... not just 3x3 for the nxn array and the remaining array is stored in a new array ... so the output will be:  < Pre>  {5,6}, {8 9}    

doing this There is no built-in method for you, you can do it yourself:

  Fixed zero main () {int [,] array = {{1, 2, 3}, {4, 5 , 6}, {7, 8, 9}}; Var trim = trimayer (0, 2, array); } Public static int [,] trimayer (int rotaryowow, int colormoormow, int [,] original array) {int [,] result = new int [original array. Gatt Loughgh (0) - 1, Original Array. Gate Lath (1) - 1]; (Int i = 0, j = 0; i & lt; original array.gate lamps (0); i ++) {if (i == rowtomov) continues; For (int k = 0, u = 0; k & gt; originalArray.GetLength (1); k ++) {if (k == columnToRemove) is in progress; Result [J, U] = Original Array [I, Kashmir]; U ++; } J ++; } Return results; }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -