如何知道字符串的字节的大小? [英] How to know the size of the string in bytes?
本文介绍了如何知道字符串的字节的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如果我能知道过了多久在在C#中的字符串
字节,谁知道?
I'm wondering if I can know how long in bytes for a string
in C#, anyone know?
推荐答案
您可以像使用ASCII编码使用,让每一个字节一个字符 System.Text.Encoding
类。
You can use encoding like ASCII to get a character per byte by using the System.Text.Encoding
class.
或尝试这种
System.Text.ASCIIEncoding.Unicode.GetByteCount(string);
System.Text.ASCIIEncoding.ASCII.GetByteCount(string);
这篇关于如何知道字符串的字节的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文