如何从字符串中设置整数Hex Literal,

我试图从xml设置文件加载一个hex文字,我可以很好地解析xml并从文件中获取所需的字符串,

但我似乎无法设置一个int变量值:/

码:

int PlayerBaseAddress = System.Convert.ToInt32(ConfigLoader.GetSetting("PlayerBaseAddress")); // Input string was not in a correct format. public static string GetSetting(string Val) { // This loads from the xml file, Pretend its hardcoded to return a string of 0x17EAAF00 } int PlayerBaseAddress = 0x17EAAF00; // This works. 

您必须将字符串的基础提供给重载方法Convert.ToInt32(String value, Int32 fromBase)

 Int32 value = Convert.ToInt32(hexString, 16);