- string sen1 = "abcdef";
- Console.WriteLine(System.Text.Encoding.Default.GetByteCount(sen1));//6字节
- string sen2 = "串";
- Console.WriteLine(System.Text.Encoding.Default.GetByteCount(sen2));//2字节
- string sen3 = "abcdef串";
- Console.WriteLine(System.Text.Encoding.Default.GetByteCount(sen3));//8字节
- Console.ReadKey();
复制代码 |