bolek Posted May 13, 2005 Posted May 13, 2005 Hi, how do I read hexadecimal numbers from a file? Or better, how to type them to the file? I tried the System.Convert.ToUInt32( string) function but it failes for numbers like 0x12345678. Also, is there please anything like the C/C++ sscanf function? Thanks for replies Quote
Leaders snarfblam Posted May 13, 2005 Leaders Posted May 13, 2005 To parse a hex number, you must first manually remove the "0x" from the beginning. Then you can use the Integer.Parse() function. Integer.Parse(MyString, Globalization.NumberStyles.HexNumber) The Integer.ToString() function has an overload that allows you to specify formats. You can use either the uppercase hex format specifier ("X", yields "0123456789ABCDEF") or the lower case hex format specifier ("x", yields "0123456789abcdef"). MessageBox.Show(MyInt.ToString("X")) Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.