/**//// <summary>
/// 精確截取字符串長度
/// </summary>
/// <param name="str">字符串</param>
/// <param name="length">截取的長度</param>
/// <returns>返回截取後的字符串</returns>
public static string CutString(string str,int length)
...{
return CutString(str,length,"..");
}
/**//// <summary>
/// 精確截取字符串長度
/// </summary>
/// <param name="str">需要截取的字符串</param>
/// <param name="length">截取的字符串長度</param>
/// <param name="overstr">大於截取部分表示方式</param>
/// <returns></returns>
public sstring CutString(string str,int length,string overstr)
...{
length=length*2;
str = str.Trim();
byte[] buffer1= Encoding.Default.GetBytes(str);
if (buffer1.Length > length)
...{
string text1 = "";
for (int num1 = 0; num1 < str.Length; num1++)
...{
byte[] buffer2 = Encoding.Default.GetBytes(text1);
if (buffer2.Length >= length)
...{
break;
&n }
text1 = text1 + str.Substring(num1, 1);
}
return (text1 +overstr);
}
return str;
}