Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error on

C#
Convert.ToInt32(7b, 16);


Where 7b is in hexadecimal. I want conversion from hexadecimal to decimal
Posted
Updated 20-Mar-14 0:47am
v2

 
Share this answer
 
v3
Please have a look on the bellow link :
How to convert numbers between hexadecimal and decimal in C#?[^]
 
Share this answer
 
v2
Try Convert.ToInt32("7b", 16);.
Quotes indicating string are missing.
 
Share this answer
 
Comments
DoingWork 20-Mar-14 14:56pm    
Yes you are right. I actullay passed here string type variable in which 7b is stored.
Hello you can do it following way

C#
//Convert.ToInt32(7b, 16);
           string hexValue = "7b";
           //First way
           int decValue = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
           //second way
           int decValue2 = Convert.ToInt32(hexValue, 16);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900