C# – How to remove the first element in an array?


I have an array:


I want to remove only arr[0], and keep arr[1] and arr[2].
I was using:

arr= arr.Where(w => w != arr[0]).ToArray();  

Since arr[0] and arr[2] have the same value ("a"), the result I'm getting is only arr[1].

How can I return both arr[1] and arr[2], and only remove arr[0]?

Best Answer

You can easily do that using Skip:

arr = arr.Skip(1).ToArray();  

This creates another array with new elements like in other answers. It's because you can't remove from or add elements to an array. Arrays have a fixed size.