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();
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2022-03-06
  • 2021-07-09
猜你喜欢
  • 2022-12-23
  • 2022-01-12
  • 2021-07-28
  • 2022-12-23
  • 2021-06-06
  • 2021-10-13
  • 2022-01-09
相关资源
相似解决方案