0
How to remove the first item from an array without for or foreach.
I tried this, but it says that there is no method to remove or remove.
int[] arr = {1,2,3,4,5};
var removeu = Array.Remove(arr,0);//Agora percebi que isso é javascript, rs
This is a mistake. How do I do it? I passed it to a list, but it was a mistake too.
List<int> lista = new List<int>(arr);
lista.Remove(0);
// Zero here not the first index.
Like I do now?
tries to use removeAt
– DiegoAugusto
list.Removeat(0);
– DiegoAugusto
The problem with Removeat is that it is void and I cannot assign the value removed like this: var first = list.Removeat(0); This gives error.
– pnet
If you want to remove the element, that’s it, if you want to assign the element before removing it, just do it before removing it
– Maniero
@pnet solved the problem?
– Maniero
Solved, not in the proposed way I wanted but resolves, both answers solve. I know, still close the post. I will close yes.
– pnet