标签:foreach rem str isnull string lambda表达式 ons oar 过滤
static void Main(string[] args) { string[] strArray = { "","111","","222","","333"}; Console.WriteLine("输出带有空字符串的数组:"); foreach (string str in strArray) { Console.WriteLine(str); } Console.WriteLine("-------------------------------------------"); //使用lambda表达式过滤掉空字符串 strArray = strArray.Where(s=>!string.IsNullOrEmpty(s)).ToArray(); Console.WriteLine("输出过滤掉空字符串的数组:"); foreach (string str in strArray) { Console.WriteLine(str); } Console.Read(); }
标签:foreach rem str isnull string lambda表达式 ons oar 过滤
原文地址:http://www.cnblogs.com/yabisi/p/6140771.html