2

xml設定ファイルから16進リテラルを読み込もうとすると、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.
4

1 に答える 1

7

文字列のベースをオーバーロードされたメソッドに指定する必要がありますConvert.ToInt32(String value, Int32 fromBase)

Int32 value = Convert.ToInt32(hexString, 16);
于 2009-05-11T16:22:19.543 に答える