I would like to use a row and column removing method in my array. Therefore I wanted to convert my array to ArrayList to use the RemoveAt(int index) method, but in Windows 8 Apps using .NET 4.5 there is no ArrayList. Could you give me a suggestion how to cast my simple int[,] array to another type, which has a row and column removing method?
I would like to use a row and column removing method in my array.
Share
You could just use a list of lists:
And initialize it as follows
Using this approach,
array.RemoveAt(row)would remove an entire row, whereasarray[row].RemoveAt(col)would remove an element.EDIT: As phoog indicated, the above initialization would need to be modified for an array declared as int[,], as follows:
The advantage to using a jagged array (as opposed to a rectangular array) in this case is being able to access entire rows, without the need to explicitly loop through the values.