Go to: http://www.cnblogs.com/fwind/archive/2012/04/13/2445380.html
In C #, the decimal and 16 binary conversions are simple, as follows:
Decimal to hexadecimal:
int - = a.tostring ("x8");
Hexadecimal to decimal:
int b= int32.parse ("266", System.Globalization.NumberStyles.HexNumber);
You can also use the following methods:
/// <summary> ///hexadecimal conversion to decimal/// </summary> /// <param name= "Strcolorvalue" ></param> /// <returns></returns> Public Static intGethexadecimalvalue (String strcolorvalue) {Char[] Nums =Strcolorvalue.tochararray (); intTotal =0; Try { for(inti =0; I < Nums. Length; i++) {String strnum=Nums[i]. ToString (). ToUpper (); Switch(strnum) { Case "A": Strnum="Ten"; Break; Case "B": Strnum=" One"; Break; Case "C": Strnum=" A"; Break; Case "D": Strnum=" -"; Break; Case "E": Strnum=" -"; Break; Case "F": Strnum=" the"; Break; default: Break; } DoublePower = Math.pow ( -, Convert.todouble (nums. Length-i-1)); Total+ = Convert.ToInt32 (strnum) *Convert.ToInt32 (Power); } } Catch(System.Exception ex) {String Strerorr=Ex. ToString (); return 0; } returnTotal ; }
C # decimal and 16 binary conversions