0

I want to remove an element of this array

int[,] numbers = { {1,0} , {3,4} , {9,2} , {4,0} };  
int[,] Remove = {{4,0}};  
4
  • 5
    You cannot "remove" elements from an array, because they're fixed size. Commented Apr 10, 2015 at 8: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? Commented Apr 10, 2015 at 8:23
  • stackoverflow.com/questions/8032394/… refere this Commented Apr 10, 2015 at 8:32
  • Try this, stackoverflow.com/questions/7992728/… Commented Apr 10, 2015 at 9:17

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.