中文字符的长度

string strTmp = "中国";
int a = System.Text.Encoding.Default.GetBytes(strTmp).Length;
int b = strTmp.Length;

Console.WriteLine(a);  //  4
Console.WriteLine(b);  //  2

posted @ 2021-12-21 15:57  艾特-天空之海  阅读(85)  评论(0编辑  收藏  举报