If I’m using an ArrayList in C#.NET, is the order guaranteed to stay the same as the order I add items to it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, elements are always added to the end (unless you specify otherwise, e.g. with a call to Insert). In other words, if you do:
The position will change if you remove any earlier elements or insert new elements ahead of it, of course.
Is there any good reason for you to use
ArrayListrather thanList<T>by the way? Non-generic collections are so 2003…(The order is stable in
List<T>as well, by the way.)