Wednesday, 22 May 2013

string[] remove null (string array remove Null)

string[] items = new string[]
{ "", "Name1", "Name2", null, "Name3", "Name4", null, "Name5" };
 
Solutions :   
items = items.Where(s => !String.IsNullOrEmpty(s)).ToArray(); 

No comments:

Post a Comment