简体   繁体   中英

How to delete an element from an array[,]?

I want to remove an element of this array

int[,] numbers = { {1,0} , {3,4} , {9,2} , {4,0} };  
int[,] Remove = {{4,0}};  

You cannot remove items from an Array because they are a fixed size I would use:

List<Tuple<int,int>>

this way you still have a list of two dimensional objects with the ability to remove them as well using

List.Remove()

You can't - arrays are fixed size. You can set the value to null. Best is to use generic collections such as List<int[]> which will allow you to add, insert and remove values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM