A Question about converting between string and int32

Hi, all

In the program I get a string "0x100" from a file, I wonder how to convert it to Int32

It warns me wrong when i use the Convert.ToInt32( "0x100").

The result I want is 256.

Thx all.



Answer this question

A Question about converting between string and int32

  • kkirtac

    int n = Int32.Parse("0x100", Globalization.NumberStyles.HexNumber)

  • Korol

    Try specify the good NumberFormat:


    Int32 myInt = In32.Parse( "0x100", System.Globalization.NumberStyles.HexNumber );



  • A Question about converting between string and int32