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

推荐订阅源

V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
L
LangChain Blog
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
Y
Y Combinator Blog
月光博客
月光博客
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
小众软件
小众软件
H
Help Net Security
Last Week in AI
Last Week in AI
B
Blog RSS Feed
宝玉的分享
宝玉的分享
N
Netflix TechBlog - Medium
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog

博客园 - 书生

乐在其中设计模式(C#)系列文章索引 C#事件(event)解析 C#之委托的个人理解 NUnit2.0使用简单教程 如何将自己的代码自动添加版权信息的及其扩展 - 书生 - 博客园 浅谈.NET中的数据绑定表达式(二) - 书生 - 博客园 经典SQL语句集锦(收藏版) Community Server的HttpHandler .NET继承本质论 如何将自己的代码自动添加版权信息 谈谈C#中的三个关键词new , virtual , override VS中常见的扩展名,看看你知道几个? 关于数据绑定表达式 读写xml节点的数据总结 Asp.net(C#)实现验证码功能 自定义编码解析函数示例 常用正则表达式,已封装为静态方法, 将自定义对象序列化为XML字符串 设置或者得到CheckBoxList选中了的值
获得字符串长度(中文字符占2) - 书生 - 博客园
书生 · 2008-03-27 · via 博客园 - 书生

获得字符串长度(中文字符占2) 

 1/// <summary>
 2/// 字符串长度
 3/// </summary>
 4/// <param name="strStr"></param>
 5/// <returns></returns>

 6private int GetStringLength(string strStr)
 7{
 8    Encoding encoding =  Encoding.GetEncoding("GB2312");
 9    byte[] bstrLength = encoding.GetBytes(strStr);
10    return bstrLength.Length;
11}