惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements

博客园 - 风语战士

asp.net 命名规范 CSS 色彩值... 请问 CType和DirectCast函数有何区别 soundex RadMenu菜单的父节指定image - 风语战士 - 博客园 从数据库中存取二进制数据并显示 - 风语战士 - 博客园 vs2005 web.config大全 javascript中showModalDialog和showModelessDialog的使用 设为主页 - 风语战士 - 博客园 CSS样式表 表达是做为参数验证用 DataList翻页 .net安全防止写不规范字付 引用一个falsh使它显示出来 删除成功后.添加前.可判断 弹出另一页面 (转)VS2005(c#)项目调试问题解决方案集锦 常用正则表达式 在ASP.NET中使用Session常见问题集锦
截取字付串
风语战士 · 2007-12-25 · via 博客园 - 风语战士

public static string GetString(string str, int length )
        {
            int i = 0, j = 0;
            foreach (char chr in str)
            {
                if ((int)chr >30)
                {
                    i += 2;
                }
                else
                {
                    i++;
                }
                if (i > length)
                {
                    str = str.Substring(0, j) + "...";
                    break;
                }
                j++;
            }
            return str;

        }
        #endregion