# region 方法:string TransString(string, int)按字符串的实际长度截取定长字符串
public static string TransString(string Str,int Length)
{
int i = 0, j = 0;
foreach (char Char in Str)
{
if ((int)Char > 127)
i += 2;
else
i ++;
if (i > Length)
{
Str = Str.Substring(0, j) + "...";
break;
}
j ++;
}
return Str;
} # endregion
public static string TransString(string Str,int Length)
{
int i = 0, j = 0;
foreach (char Char in Str)
{
if ((int)Char > 127)
i += 2;
else
i ++;
if (i > Length)
{
Str = Str.Substring(0, j) + "...";
break;
}
j ++;
}
return Str;
} # endregion
解决方案 »
- |zyciis| javascript中的function传进来一个function的时候,如何判断他的第一个参数和改变他的第一个参数 谢谢 示示例
- 如何在asp.net的回发中中止当前的线程?
- 怎样再后台 得到 动态生成的DIV(JS生成的)的 各种属性,在线等
- 奇怪的问题: ASPX2.0 页面中文本框 tbxName 在后台文件代码中 strName = tbxName.text.trim()无法获得?
- detailsview中DropDownlist使用的问题!
- 关于WebForm中DropDownList字符串超长的问题
- 为什么要处理异步请求??
- ScriptManager.RegisterStartupScript传值到另一个窗口,窗口关闭不掉~~~~急急
- Please tell me where can I download some ebooks of ASP.net
- 求教高级搜索
- 我急需一个上传图片到access数据库和从access数据库读取出图片的例子,请帮帮我啊
- parent.aspx页面用了ifarme ifarme的scr=test.aspx ,点击parent.aspx的button 响应test.cs里 save()函数
{
if(e.Item.ItemIndex>-1)
{
if(e.Item.Cells[2].Text.Length>22)
{
e.Item.Cells[2].Text=e.Item.Cells[2].Text.Substring(0,22).ToString()+"...."; }
}
}
能看明白吗?
揭贴