1)方法:

public static string SubStr1(string oldStr, int maxLength, string endWith)

{

if (string.IsNullOrEmpty(oldStr))

//?? throw?? new?? NullReferenceException( “原字符串不能为空 “);

return oldStr + endWith;

if (maxLength maxLength)

{

string strTmp = oldStr.Substring(0, maxLength);

if (string.IsNullOrEmpty(endWith))

return strTmp;

else

return strTmp + endWith;

}

return oldStr;

}

前台调用:

2)方法:

public string SubStr(string sString, int nLeng) ///实现和上面的方法同样的功能

{

if (sString.Length

?

本文原创,转载请注明出处!!

本文地址:http://happysnail.org/index.php/archives/74