string str = "abcd";
string[] substrs = str.Split(',');
int length = substrs.Length;
Console.WriteLine(length.ToString());
Console.ReadLine();
Actually, if the string "abcd" can not be seperated by ",". It can be regarded as whole. so it return "1". but if the "," are included in the string, it can be split. such as if the code is:
string str = "a,b,c,d";
string[] substrs = str.Split(',');
int length = substrs.Length;
Console.WriteLine(length.ToString());
Console.ReadLine();
it return as 4. if only "a,b,c" it returns 3. in your code, even it is empty, but it is a string, the string is taken as a whole, so it returns 1.
Never give up! Smile to the world!
http://excelcsharp.blog.com/
Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator