温馨提示×

C#中Split方法是否支持Unicode字符

c#
小樊
84
2024-07-20 23:46:55
栏目: 编程语言

是的,C#中的Split方法支持Unicode字符。通过指定Unicode字符作为分隔符,可以轻松地对包含Unicode字符的字符串进行拆分操作。例如:

string input = "Hello, 你好, Bonjour";
char[] separators = new char[] { ',', ' ', ',' };
string[] result = input.Split(separators, StringSplitOptions.RemoveEmptyEntries);

foreach (string s in result)
{
    Console.WriteLine(s);
}

在上面的例子中,我们使用了包含英文逗号、空格和中文逗号的字符数组作为分隔符,成功对包含Unicode字符的字符串进行了拆分操作。

0