日期:2014-05-20  浏览次数:20660 次

如何判断段数据最后是否有';'符号
如一段这样的:a;b;c;d;e;f
如果f后面有;分号,则显示出a;b;c;d;e;f;
如果f后面没有;分号,则在f后面加上分号,再显示出a;b;c;d;e;f;

------解决方案--------------------
用String.EndsWith 方法
------解决方案--------------------
比如:
string str = "a;b;c;d;e;f ";
if (!str.EndsWith( "; "))
{
str += "; ";
}
System.Console.WriteLine(str);
------解决方案--------------------
string.TrimEnd( '; ') + "; "
------解决方案--------------------
string a = "1;2;3;4;5 ";
if (!a.EndsWith( "; "))
{
a += "; ";
}
Response.Write(a);