-1

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

Anirudha
  • 32,393
  • 7
  • 68
  • 89
alostr
  • 170
  • 2
  • 2
  • 11

1 Answers1

1

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();
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
  • I just simplified the code here, I am actually using a different regex.... You think that if after this code I will print the strings in the list I will always get the string I started with? – alostr Nov 12 '13 at 15:10