web 截取文字长度,并使用…代替多余的文字
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
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 WEIXING.ME!
