public static class NumericHelper
{
// 将十进制数转换为二进制字符串
public static string DecimalToBinary(int number)
{
return Convert.ToString(number, 2);
}
// 将十进制数转换为八进制字符串
public static string DecimalToOctal(int number)
{
return Convert.ToString(number, 8);
}
// 将十进制数转换为十六进制字符串
public static string DecimalToHexadecimal(int number)
{
return Convert.ToString(number, 16);
}
// 将二进制字符串转换为十进制数
public static int BinaryToDecimal(string binary)
{
return Convert.ToInt32(binary, 2);
}
// 将八进制字符串转换为十进制数
public static int OctalToDecimal(string octal)
{
return Convert.ToInt32(octal, 8);
}
// 将十六进制字符串转换为十进制数
public static int HexadecimalToDecimal(string hexadecimal)
{
return Convert.ToInt32(hexadecimal, 16);
}
}
标签:Convert,转换,进制,C#,number,int,static,return,public From: https://www.cnblogs.com/yzlong520/p/18202796