I use LINQ to Objects instructions on an ordered array. Which operations shouldn’t I do to be sure the order of the array is not changed?
I use LINQ to Objects instructions on an ordered array. Which operations shouldn’t I
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.
I examined the methods of System.Linq.Enumerable, discarding any that returned non-IEnumerable results. I checked the remarks of each to determine how the order of the result would differ from order of the source.
Preserves Order Absolutely. You can map a source element by index to a result element
Preserves Order. Elements are filtered or added, but not re-ordered.
Destroys Order – we don’t know what order to expect results in.
Redefines Order Explicitly – use these to change the order of the result
Redefines Order according to some rules.
Edit: I’ve moved Distinct to Preserving order based on this implementation.