未删除空白项
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
string number = "0,,1..2,,3;;456789";
string[] strs = number.Split(new char[] { ',', '.', ';' });
foreach (var item in strs)
{
Console.WriteLine(item);
}
Console.ReadKey();
}
}
}
删除空白项 - StringSplitOptions.RemoveEmptyEntries
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
string number = "0,,1..2,,3;;456789";
string[] strs = number.Split(new char[] { ',', '.', ';' },
options: StringSplitOptions.RemoveEmptyEntries);
foreach (var item in strs)
{
Console.WriteLine(item);
}
Console.ReadKey();
}
}
}