本文介绍了修改/获取整数形式的字符串中的字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人
我想以整数格式获取字符串的字节.请任何人帮我!
感谢您的回答;我想要一个整数字符串的大小.任何人都可以清楚地回答我的问题.
Dear All
I want to get bytes of a string in an integer format. please any one help me!
Thanks for your answers; I want the size of a string in integer. any one clearly answer my question please.
推荐答案
private byte[] StringToByteArray(string str)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetBytes(str);
}
和例如您可以执行的按钮单击事件:
and in e.g. a button click event you can do:
byte[] arr = StringToByteArray("Hello");
另请参阅Hiren Solanki的答案以获取更多信息.
Please also see Hiren Solanki''s answer for more information.
这篇关于修改/获取整数形式的字符串中的字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!