using System.Text.RegularExpressions;
public static void Main()
string arr2 = "a;b;c;d;e";
string arr3 = "aaaa;bbbbb;ccccc;ddddd;eeeee;fffff;ggggg";
string arr4 = "aaaa;bbbbb;ccccc;ddddd;eeeee;fffff;ggggg;hhhhh;iiiii;jjjjj;kkkkk;lllll;mmmmm;nnnnn;ooooo;ppppp;qqqqq;rrrrr;sssss;ttttt;uuuuu;vvvvv;wwwww;xxxxx;yyyyy;zzzzz;aaaa;bbbbb;ccccc;ddddd;eeeee;fffff;ggggg;hhhhh;iiiii;jjjjj;kkkkk;lllll;mmmmm;nnnnn;ooooo;ppppp;qqqqq;rrrrr;sssss;ttttt;uuuuu;vvvvv;wwwww;xxxxx;yyyyy;zzzzz;aaaa;bbbbb;ccccc;ddddd;eeeee;fffff;ggggg;hhhhh;iiiii;jjjjj;kkkkk;lllll;mmmmm;nnnnn;ooooo;ppppp;qqqqq;rrrrr;sssss;ttttt;uuuuu;vvvvv;wwwww;xxxxx;yyyyy;zzzzz";
System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
for (int i = 0; i < 100000; i++)
Console.WriteLine("Execution time 1: {0} ms", sw.ElapsedMilliseconds);
for (int i = 0; i < 100000; i++)
Console.WriteLine("Execution time 2: {0} ms", sw.ElapsedMilliseconds);
for (int i = 0; i < 100000; i++)
Console.WriteLine("Execution time 3: {0} ms", sw.ElapsedMilliseconds);
public static int test1(string arr, char splitChar)
while (index < arr.Length)
int charIndex = arr.IndexOf(splitChar, index);
public static int test2(string arr, char splitChar, int maximum = -1)
while (index < arr.Length && count <= maximum)
int charIndex = arr.IndexOf(splitChar, index);
public static int test3(string arr, char splitChar)
return arr.Split(splitChar).Length;