tags:

views:

1032

answers:

4

string[] ssss = "1,2,,3".Split(new[] {','}).Where(a=>!string.IsNullOrEmpty(a)).Select()

How does this works?

+3  A: 
string[] ssss = "1,2,,3".Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries);
bruno conde
well done, I had forgotten that option ;)
Thomas Levesque
+3  A: 

You could also use

"1,2,,3".Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
Kobi
A: 
var ssss = "1,2,,3".Split(new[] {','}).Where(a=>!string.IsNullOrEmpty(a));
foreach (string s in ssss)
{
    Console.WriteLine(s);
}
uzay95
+1  A: 
string[] ssss = "1,2,,3".Split(new[] {','}).Where(a=>!string.IsNullOrEmpty(a)).ToArray();
Thomas Levesque