本文介绍了C#中的十六进制操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在c#中对十六进制值进行解析/转换/操作的任何提示?
特别是我想将十进制int转换为十六进制,然后以字符串形式输出。
解决方案
Int32 decValue = 42;
string hexValue = decValue.ToString(X);
Int32 decValue2 = Int32.Parse(hexValue,System.Globalization.NumberStyles.HexNumber);
看到这篇文章:
Any hints on parsing / converting / operating on hex values in c# ?
In particular I want to cast a decimal int to hex and then output as a string...
解决方案
Int32 decValue = 42;
string hexValue = decValue.ToString("X");
Int32 decValue2 = Int32.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
See this post:
How to convert numbers between hexadecimal and decimal in C#?
这篇关于C#中的十六进制操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!