将字符串转换为十六进制数 [英] Convert string to hex number

查看:114
本文介绍了将字符串转换为十六进制数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!我遇到了麻烦。我有一个文本框,数据字符串如E4。如何将此textbox.text数据转换为相等的十六进制数E4? E4到&HE4

解决方案

你绝对会惊讶地发现这个:

http://msdn.microsoft.com/en-us/library/bb311038.aspx [ ^ ]



请阅读发布问题之前的文档。 :)


十六进制,八进制,十进制,二进制:它们只是相同数字的表示。没有十六进制数4E,只有值78.你可以解析十六进制表示来获得这个值,并再次感谢你想要的格式 - 但你真的需要这个吗?

检查以下代码行逐个:

  var  input =    4E; 
var x = Convert.ToInt32(输入, 16 );
Console.WriteLine( String .Format( &安培; H {0:X}中,x));
Console.WriteLine( String .Format( &安培; H {0},输入));


Hello! I have a trouble. I have a textbox with data as string like "E4". How to convert this textbox.text data to a equal hex number E4? "E4" to &HE4

解决方案

You would absolutely be amazed to find this:
http://msdn.microsoft.com/en-us/library/bb311038.aspx[^]

Pleas read the documentation before posting a question. :)


Hexadecimal, octal, decimal, binary: they are only representations of the same number. There is no hex number 4E, there is only the value 78. You can parse the hexadecimal representation to get this value, and thank back again to your desired format - but do you really need this?
Check following code lines one by one:

var input = "4E";
var x = Convert.ToInt32(input, 16);
Console.WriteLine(String.Format("&H{0:X}",x));
Console.WriteLine(String.Format("&H{0}",input));


这篇关于将字符串转换为十六进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆