In C #, the decimal and 16 binary conversions are simple, as follows:
Decimal to hexadecimal:
1 int a = 100;2 String stra = a.tostring ("x8");
Hexadecimal to decimal:
1 int b= int32.parse ("266", System.Globalization.NumberStyles.HexNumber);
You can also use the following methods:
1//<summary> 2//hexadecimal conversion to decimal 3//</summary> 4//<param name= "Strco Lorvalue "></param> 5//<returns></returns> 6 public static int Gethexadecimalvalue ( String Strcolorvalue) 7 {8 char[] nums = Strcolorvalue.tochararray (); 9 int total = 0;10 Try11 {n for (int i = 0; i < Nums. Length; i++) (String strnum = nums[i]. ToString (). ToUpper () (Strnum), [A]: 18 Strnum = "Ten"; break;20 case "B": 21 Strnum = "one"; break;23 case "C": 24 Strnum = "n"; break;26 case "D": 27 Strnum = "+"; break;29 case "E": 30 Strnum = "+"; break;32 case "F": 33 Strnum = "break;35"; default:36 break;37}38 Double power = Math.pow (Convert.todouble (nums. Length-i-1)); Total + = Convert.ToInt32 (strnum) * CONVERT.TOINT32 (Power); 40}41 4 2}43 catch (System.Exception ex), {String Strerorr = ex. ToString ();}48 return 0;47 total;51}
C # decimal and 16 binary conversions