2

How can i delete the first index(0) of a string[] array? Can't find array.RemoveAt(0); enter image description here

1
  • 4
    Consider using a List<string> if you have frequent adds/removes. It's a lot better in terms of performance. Commented Feb 10, 2014 at 2:01

1 Answer 1

5

Arrays in .NET have a fixed length, so you can't simply add or remove elements at a given location. You'd need to create a new array. The easiest way would probably be to use a little Linq:

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

But you may not need an array. If you refactor your code so that urlexploded is a List<T>, you can use RemoveAt as expected, or if you can make it an IEnumerable<T> just drop the ToArray at the end.

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

Comments

Your Answer

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