|
-
March 2nd, 2003, 10:02 AM
#1
int.Parse
I'm trying to make the following lines to work:
int i = int.Parse("0xA");
Console.WriteLine(i);
i.e: i want parse to take the hex number, convert it to int and print it.
As I read in the manual, we can add another parameter to Parse - FormatProvider, that will do the task, but I can't understand how to use that FormatProvider.
Anyone has a solution?
-
March 2nd, 2003, 10:27 AM
#2
Code:
int i = Int32.Parse("A", System.Globalization.NumberStyles.AllowHexSpecifier);
Martin
-
March 2nd, 2003, 10:33 AM
#3
Great. It works perfect. Thanks
-
March 2nd, 2003, 02:32 PM
#4
alternatively,
int a = Convert.ToInt32("0xA",16);
MessageBox.Show(a.ToString());
-Paresh
-
March 2nd, 2003, 02:37 PM
#5
can I use Convert() to convert any base?
-
March 2nd, 2003, 02:41 PM
#6
yes
2 , 8 16 etc.. octal, int, decimal 10 , hex 16 ...
Paresh
-
March 2nd, 2003, 02:44 PM
#7
cool. nice to know that, thanks
-
March 2nd, 2003, 10:50 PM
#8
specially
Convert
and
System.Text... classes are typically very important since they are the most needfull classes to change one data format to another data format.
-Thanx
Paresh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|