修改/获取整数形式的字符串中的字节 [英] Revised / Get Bytes In A String in integer format
本文介绍了修改/获取整数形式的字符串中的字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人
我想以整数格式获取字符串的字节.请任何人帮我!
感谢您的回答;我想要一个整数字符串的大小.任何人都可以清楚地回答我的问题.
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.
推荐答案
您可以使用此方法:
Hi,
you can use this method:
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.
按照JF2015提供的答案获取字符串的字节数组.
更多此处 [
Follow the answer provided by JF2015 for getting byte array of string.
Further more HERE[^] is a good article on Lovely MSDN for caring of you further.
您的意思是获取长度 [ ^ ]的字符串?
Do you mean get the Length[^] of a string?
这篇关于修改/获取整数形式的字符串中的字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文