Reputation: 170
I have a list of strings, that each string needs to split by a regex, than kept in the same list.
List<string> a = new List<string>();
a.Add("big string with a lot of words");
a=a.SelectMany(item=> Regex.Split("\r\n",item)).ToList();
I just want to make sure that this will not reorder the parts of the string that were created?
Is there a web site that has information about methods runtime and compiler optimizations?
Thanks
Upvotes: -1
Views: 773
Reputation: 148980
With Linq-to-Objects, it will not re-order the elements of the result set unless you call OrderBy
or OrderByDescending
.
However, I wouldn't use regular expressions for this, a simple string.Split
would do just fine:
List<string> a = new List<string>();
a.Add("big string with a lot of words");
a = a.SelectMany(item => item.Split(new[] { "\r\n" }, StringSplitOptions.None)).ToList();
Upvotes: 1