在我的代码中,我需要从Registry获取委内瑞拉的时区。我想要的是关键“委内瑞拉标准时间”下的指数值。我使用以下代码来执行此操作,但似乎它无法正常工作。返回的数字是“-2147483573”,但正确的数字是“2147483723”。任何人都可以帮助找出问题所在。
答案 0 :(得分:3)
值0x8000004B大于整数。您需要将其视为无符号整数。
所以:
var t = subKey.GetValue("Index");
uint ut = (uint)t;
然后选择ut.ToString()
。
更新示例:
int t = -2147483573; // Simulates your call to subKey.GetValue
uint ut = (uint)t;
string s = ut.ToString();
Console.WriteLine(s);
输出为2147483723。