本文介绍了C#中的字符串为十六进制,十六进制字节转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这需要一个十六进制值的方法并将其指定为像字节的明文,但类型
I have a method which takes a hex value and assign it as a plaintext but type of byte like that
byte plainText = 0xd7;
我想借此从文本框的这个值,〔实施例用户将键入D7到文本框,我会分配给它像
I want to take this value from textbox ,for exmaple the user will type d7 to textbox and ı will assign it like
byte plaintText = 0xd7
我不能achive这一点。
I could not achive that.
推荐答案
您可以使用的方法与基地设置为16(十六进制):
You can use the Convert.ToByte(String, Int32)
method with the base set to 16 (hexadecimal):
String text = "d7";
byte value = Convert.ToByte(text, 16);
这篇关于C#中的字符串为十六进制,十六进制字节转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!