中文字符的长度

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  二维一加零  阅读(106)  评论(0)    收藏  举报