Thursday 30 July 2009

String Spilt

#1
string demo = "";
string[] demoarray = demo.Split(";".ToCharArray());
Console.WriteLine(demoarray.Length);

#2
string demo = String.Empty;
string[] demoarray = demo.Split(";".ToCharArray());
Console.WriteLine(demoarray.Length);

What do you guess the output should be in each case?
I guessed to be Zero. But it is not. It is One, with a empty string as the first Element in both the cases.





No comments:

Post a Comment