//十进制 --> 二进制
int data = 100;
string bin = Convert.ToString(data, 2); // “1100100”
//十进制 --> 十六进制
int data = 100;
string hex = “”;
hex = Convert.ToString(data, 16); // “64”
hex = “0X” + Convert.ToString(data, 16); // “0X64”
hex = string.Format(“{0:X}”, Convert.ToInt32(input)); // “64”
hex = string.Format(“{0:X4}”, Convert.ToInt32(input)); // “0064”
hex = “0X” + string.Format(“{0:X}”, Convert.ToInt32(input)); // “0X64”
hex = “0X” + string.Format(“{0:X4}”, Convert.ToInt32(input)); // “0X0064”
//二进制 --> 十进制
string bin = “11001010”;
int dec = Convert.ToInt32(bin, 2); // 202
//二进制 --> 十六进制
string bin = “11001010”;
string hex = “”;
hex = string.Format(“{0:X}”, Convert.ToInt32(bin, 2)); // CA
hex = “0X” + string.Format(“{0:X}”, Convert.ToInt32(bin, 2)); // 0XCA
hex = “0X” + string.Format(“{0:X4}”, Convert.ToInt32(bin, 2)); // 0X00CA
//十六进制 --> 十进制
string hex = “0XE7”;
int dec = Convert.ToInt32(hex, 16); // 231
//十六进制 --> 二进制
string hex = “0XE7”;
int dec = Convert.ToInt32(hex, 16); // 231
string bin = Convert.ToString(dec, 2); // “11100111”