c#.net
c# hex to dec, dec to hex
우유빛
2009. 6. 30. 15:14
//-----------------------------------------------------------
// Dec String -> Hex String
//-----------------------------------------------------------
private string DecToHex(string s)
{
string DecToHex = "";
try
{
//decimal decs = Decimal.Parse(s);
long decs = Int64.Parse(s);
DecToHex = Convert.ToString(decs, 16).PadLeft(2,'0');
DecToHex = DecToHex.ToUpper();
}
catch (Exception ex)
{
DecToHex = ex.Message.ToString();
}
return DecToHex;
}
//-----------------------------------------------------------
// Hex String -> Dec String
//-----------------------------------------------------------
private string HexToDec(string s)
{
string HexToDec = "";
try
{
HexToDec = Convert.ToInt64(s, 16).ToString();
}
catch (Exception ex)
{
HexToDec = ex.Message.ToString();
}
return HexToDec;
}
출처 : http://www.kymia.pe.kr/gnuboard/bbs/board.php?bo_table=lec_vb&wr_id=4