Friday, September 07, 2007

C# Split Method (Ignore Empty Elements)

To ignore empty elements, use below

string s = "*jan*feb*mar*";
string[] months = s.Split("*".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
int count = months.Length;

Console.WriteLine("count = " + count.ToString());

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.