C#的split()分割字符串
在C#中 str.Split("===="); //这样是错误的,只能 str.Split(‘=‘);//参数只能是char类型的,不能是字符串的
如果非得要以字符串分割,,那么请用:
string content = "I love you=====do you know===shit";
string[] sArray = null;
sArray = System.Text.RegularExpressions.Regex.Split(content, "===", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//使用正则表达式来弄,而且不区分大小写,后面的“System.Text.RegularExpressions.RegexOptions.IgnoreCase”就是不区分大小写了
还是java用习惯了,str.split("=");//是对的
str.split("=====");//也是对的
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/71467.html