C# spilit函数的StringSplitOptions.RemoveEmptyEntries设置清除数组里的空值
using System; class Animals { private static void Main() { string[] animals = "monkey,kangaroo,,,wallaby,,devil,,".Split(",".ToCharArray(),StringSplitOptions.RemoveEmptyEntries); foreach (string animal in animals) { Console.Out.WriteLine("animal = " + animal); } Console.In.ReadLine(); } }