string str = "小王,小李,小张,";//获取字符串长度int length = str.length;
//截取除最后一位的前面所有字符
str = str.substring(0,length-1); //"小王,小李,小张";
或TrimEnd(',')
string str = "小王,小李,小张";
str.Split(',')[0].ToStr(); //小王
string str ="H=H*h,SH=S*s*0.75%2bH*h*0.25,RH=R*r*0.6%2bH*h*0.4";
str.Substring(str.LastIndexOf(",") + 1,6); ///RH=R*r
str.Remove(str.LastIndexOf(","), 6); ///H=H*h,SH=S*s*0.75%2bH*h*0.25 r*0.6%2bH*h*0.4
string s2 = form.Replace("&", ","); //把,代替掉&
包含:Contains
/// <summary>
/// 去掉<br>
/// </summary>
/// <param name="bb"></param>
/// <returns></returns>
public string ReplaceBr(string StInto)
{
string StOut = StInto;
if (StInto.Contains("<br>"))
{
StOut = StInto.Replace("<br>", "");
}
return StOut;
}