0

I want to remove an element of this array

int[,] numbers = { {1,0} , {3,4} , {9,2} , {4,0} };  
int[,] Remove = {{4,0}};  
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • 5
    You cannot "remove" elements from an array, because they're fixed size. – dcastro Apr 10 '15 at 08:23
  • 2
    Arrays are fixed size so, you would either have to create a new array minus the item you want to delete, or make like easy and just use a list? – horHAY Apr 10 '15 at 08:23
  • http://stackoverflow.com/questions/8032394/how-to-delete-a-chosen-element-in-array refere this – Ameya Deshpande Apr 10 '15 at 08:32
  • Try this, http://stackoverflow.com/questions/7992728/how-to-delete-a-row-from-a-2d-array-in-c – Shyju Apr 10 '15 at 09:17

2 Answers2

3

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()

JKennedy
  • 18,150
  • 17
  • 114
  • 198
1

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.

ofcoursedude
  • 456
  • 4
  • 10