0

The following code is just been used as an example but i can't seem to get it to work. Getting the error 'System.Array' does not contain a definition for 'Remove and no extension method 'Remove' accepting a first argument of 'System.Array' could be found.

int[] a = [1,2,3,4,5]
a = a.Remove(4)

The examples that ive seen removes the 4 from the list meaning a then = [1,2,3,5]

What is going wrong here?

Vexoids
  • 63
  • 1
  • 7
  • It is not a list that you are using, it is an array. These are different things – dotnetom Mar 29 '15 at 07:34
  • I recommend using a `List`, `Array` is for fixed elements, if you need to remove/add use `List`. That said, your question is a duplicate, if you really want to remove items from an array, use the duplicate question link above your question. – Sriram Sakthivel Mar 29 '15 at 07:36
  • you should you List a = new List { 1, 2, 3, 4, 5 }; a.Remove(4); – Anup Sharma Mar 29 '15 at 07:59

0 Answers0