using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CShapeTest
{
class Start
{
static void Main(string[] args)
{
String str = "sep,ar.ato?rst!ring";
Console.WriteLine("分割前str为:\n{0}", str);
char[] separator = { ',', '.', '?', '!' };
Console.WriteLine("分割字符为:");
for (int i = 0; i < separator.Length; i++)
{
Console.WriteLine(separator[i]);
}
Console.WriteLine();
String[] str1 = str.Split(separator);
str = "";
for (int i = 0; i < str1.Length; i++)
{
str += str1[i];
}
Console.WriteLine("分割后str为:\n{0}", str);
Console.ReadLine();
}
}
}
C#_字符串拆分Split实例方法
最新推荐文章于 2023-05-19 10:48:05 发布