public static string StringTruncat(string oldStr, int maxLength, string endWith)
{
if (string.IsNullOrEmpty(oldStr))
return oldStr + endWith;
if (maxLength < 1)
throw new Exception("返回的字符串长度必须大于[0]");
if (oldStr.Length > maxLength)
{
string strTmp = oldStr.Substring(0,maxLength);
if (string.IsNullOrEmpty(endWith))
return strTmp;
else
return strTmp + endWith;
}
return oldStr;
}