C#如何根据字节截取字符串指定长度

 public static string GetSubStr(string str, int num)
{
byte[] buffer = System.Text.Encoding.Default.GetBytes(str);
string ret = str;

if (buffer.Length > num)
{

ret = System.Text.Encoding.Default.GetString(buffer, 0, num);
}
return ret.Replace("?", "");
}

 

posted @ 2011-11-23 13:35  .NET技术  阅读(1006)  评论(0编辑  收藏  举报
网站:化妆品批发排行榜http://www.cosmetic-top.com/