int a = 10; Console.WriteLine(a.ToString("X")); //10进制转16进制 Console.WriteLine(Convert.ToString(a, 16)); //10进制转16进制 Console.WriteLine(Convert.ToString(a, 2)); //10进制转2进制 string b = "1010"; Console.WriteLine(Convert.ToInt32(b, 2)); //2进制转10进制 Console.WriteLine(string.Format("{0:X}", Convert.ToInt32(b, 2)));//2进制转16进制 int c = 0x0a; Console.WriteLine(Convert.ToString(c, 2)); //16进制转2进制 Console.WriteLine(Convert.ToString(c, 10)); //16进制转10进制
原文地址:https://www.cnblogs.com/yincq/p/12095876.html
时间: 2024-10-08 15:15:06