下面这段代码,谁能帮我解释一下,谢谢了!public string _deal = "{%}"; //分隔符 public string getTileCity(string title) { string[] stringSeparators = new string[] { _deal }; //分割字符串 string[] titles =
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 06:23:06
下面这段代码,谁能帮我解释一下,谢谢了!public string _deal = "{%}"; //分隔符 public string getTileCity(string title) { string[] stringSeparators = new string[] { _deal }; //分割字符串 string[] titles =
下面这段代码,谁能帮我解释一下,谢谢了!
public string _deal = "{%}"; //分隔符
public string getTileCity(string title) {
string[] stringSeparators = new string[] { _deal };
//分割字符串
string[] titles = title.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
if (titles.Length > 1)
return "["+titles[0]+"]";
return "";
}
下面这段代码,谁能帮我解释一下,谢谢了!public string _deal = "{%}"; //分隔符 public string getTileCity(string title) { string[] stringSeparators = new string[] { _deal }; //分割字符串 string[] titles =
public string _deal = "{%}"; //定义分隔符
public string getTileCity(string title) {
//定义字符串分割规则
string[] stringSeparators = new string[] { _deal };
//分割字符串
//将title字符串按照{%}规则分割 成字符串数组 不包含空的项
string[] titles = title.Split(stringSeparators,StringSplitOptions.RemoveEmptyEntries);
//如果分割的数组长度大于1
if (titles.Length > 1)
return "["+titles[0]+"]";//返回[+第一个分割项+
return "";//返回空
}