用单字符分割字符串大家应该很熟悉,例如:
string source = "dfd^Afdf^AAAAAA^Adfdf";
var list= source.Split(‘A‘);
可是我们遇到这么一个场景,用多字符(字符串)分割字符串,方法:
string source = "dfd^Afdf^AAAAAA^Adfdf"; string[] stringSeparators = new string[] { "^A" }; string[] result = source.Split(stringSeparators, StringSplitOptions.None); foreach (string s in result) { Console.Write(s); }
时间: 2024-10-24 06:14:49