Feedback

Umwandlung von Hexadezimal Dezimal

Sprache: C#

Umwandlung von Hexadezimal <> Dezimal
// Hexadezimal nach Dezimal
public static int HexToDec(string hexValue)
{
    return Int32.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
}

// Dezimal nach Hexadezimal
public static string DecToHex(int decValue)
{
    return string.Format("{0:x}", decValue);
}

// Benutzung
string hex = DecToHex(15);
int dec = HexToDec("f");
// Hexadezimal nach Dezimal
public static int HexToDec(string hexValue)
{
    return Int32.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
}

// Dezimal nach Hexadezimal
public static string DecToHex(int decValue)
{
    return string.Format("{0:x}", decValue);
}

// Benutzung
string hex = DecToHex(15);
int dec = HexToDec("f");