Fluent googling doesn’t give an answer, so question is:
Does String.Split method ensure order of resulted substrings in according to they position in initial string?
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.
According to what ILSpy shows on the internals of
string.Split, the answer is yes.All elements (e.g. the
arrayvariable) are always processed in ascending order and no sorting occurs.The MSDN documentation for
string.Splitalso lists examples which have results in the same order as their order in the original string.As Jim Mischel points out above, this is only the current implementation, which might change.