Pergunta

Im tentar carregar um literal hexadecimal a partir de um arquivo de configurações XML, eu posso analisar o XML bem e obter a seqüência exigida a partir do arquivo,

mas eu não posso parecer começá-lo para definir um valor de variáveis ??int: /

Código:

    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.
Foi útil?

Solução

Você tem que fornecer a base da cadeia para o método sobrecarregado Convert.ToInt32(String value, Int32 fromBase) .

Int32 value = Convert.ToInt32(hexString, 16);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top