判断字符串长度
2009-01-05 10:14
197 查看
static void Main(string[] args)
{
string a = "abcdefg";
string b = "abcdefg中华人民共和国";
Console.WriteLine(System.Text.Encoding.Default.GetBytes(a).Length);
Console.WriteLine(System.Text.Encoding.Default.GetBytes(b).Length);
}
输出:
7
21
{
string a = "abcdefg";
string b = "abcdefg中华人民共和国";
Console.WriteLine(System.Text.Encoding.Default.GetBytes(a).Length);
Console.WriteLine(System.Text.Encoding.Default.GetBytes(b).Length);
}
输出:
7
21
相关文章推荐
- js判断字符串长度
- 文章标题字符串长度的判断
- 根据输入的字符串,判断并输出有效的字符串的长度,和该字符串。vc++
- Java 判断字符串的存储长度
- Shell脚本计算字符串长度和判断字符串为空小技巧
- shell 字符串为空和长度的判断
- PHP判断中文字符串的长度和字节长度
- 把一个数组里面的每一个字符串取出来 判断这个字符串的长度是不是大于10 判断完了 再放到一个数组里面
- 如何判断含有中文的字符串长度
- shell判断字符串长度
- java 判断含有中文的字符串的长度
- PHP 字符串长度判断效率更高的方法
- 面试题初级-求字符串最后一个单词的长度和判断ip地址的合法性
- Android判断输入的是电话号码,判断字符串长度,以及只允许数字输入
- 判断是否为指定长度内字符串的php函数
- 判断字符串长度,忽略中英文
- “设计一个方法判断字符串长度,一个汉字长度为1”?
- JS字符串长度判断,超出进行自动截取的实例(支持中文)
- php判断字符串长度 isset()速度比strlen()更快