由于负数以补码存储,您必须首先确定字符串对应的实际数字类型,否则的话是不能正确转为负数的。比如一个字符串代表32位整数:
string hex = "EA4F3290";
int dec = int.Parse(hex,
System.Globalization.NumberStyles.AllowHexSpecifier);
Console.WriteLine(dec);
输出结果为-363908464;如果把int改为long则输出:3931058832。
Tech Blog:
http://gildor.cnblogs.com