C# Program for Converting Hexadecimal String to Integer Last Updated : 02 Jul, 2020 Comments Improve Suggest changes Like Article Like Report Given an hexadecimal number as input, we need to write a program to convert the given hexadecimal number into equivalent integer. To convert an hexadecimal string to integer, we have to use Convert.ToInt32() function to convert the values. Syntax: Convert.ToInt32(input_string, Input_base); Here, input_string is the input containing hexadecimal number in string format.input_base is the base of the input value – for a hexadecimal value it will be 16. Examples: Input : 56304 Output : 353028 Input : 598f Output : 22927 If we input wrong value for eg. 672g, it shows error: Enter a hexadecimal number: System.FormatException: Additional unparsable characters are at the end of the string. If we input number greater than 8 digit e.g. 746465789, it shows error: Enter a hexadecimal number: System.OverflowException: Arithmetic operation resulted in an overflow. Program 1: C# // C# program to convert array // of hexadecimal strings to integers using System; using System.Text; class Program { static void Main(string[] args) { // hexadecimal number as string string input = "56304"; int output = 0; // converting to integer output = Convert.ToInt32(input, 16); // to print the value Console.WriteLine("Integer number: " + output); } } Output: Integer number: 353028 Program 2: C# // C# program to convert array // of hexadecimal strings // to integers using System; using System.Text; namespace geeks { class GFG { static void Main(string[] args) { string input = ""; int output = 0; try { // input string Console.Write("Enter a hexadecimal number: "); input = Console.ReadLine(); // converting to integer output = Convert.ToInt32(input, 16); Console.WriteLine("Integer number: " + output); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } // hit ENTER to exit Console.ReadLine(); } } } Input: 598f Output: Enter a hexadecimal number: Integer number: 22927 Comment More infoAdvertise with us Next Article C# Program to Convert a Binary String to an Integer S shivanisinghss2110 Follow Improve Article Tags : C# C# Programs Similar Reads C# Program to Convert a Binary String to an Integer Given an binary string as input, we need to write a program to convert the binary string into equivalent integer. To convert an binary string to integer, we have to use Convert.ToInt32(String, Base/Int32) function to convert the values. The base of the binary is 2. Syntax: Convert.ToInt32(String, Ba 2 min read C# | Uri.FromHex() Method Uri.FromHex(Char) Method is used to get the decimal value of a hexadecimal digit. Syntax: public static int FromHex (char digit); Here, it takes the hexadecimal digit (0-9, a-f, A-F) to convert. Return Value: This method returns an Int32 value that contains a number from 0 to 15 that corresponds to 2 min read C# | Uri.FromHex() Method Uri.FromHex(Char) Method is used to get the decimal value of a hexadecimal digit. Syntax: public static int FromHex (char digit); Here, it takes the hexadecimal digit (0-9, a-f, A-F) to convert. Return Value: This method returns an Int32 value that contains a number from 0 to 15 that corresponds to 2 min read Convert a string to hexadecimal ASCII values Given a string as input, write a program to convert the characters of the given string into the hexadecimal equivalent of ASCII values. Examples : Input: GeekOutput: 4765656b Input: IronMan part 3Output :49726f6e4d616e20706172742033 ASCII stands for American Standard Code for Information Interchan 7 min read Convert a string to hexadecimal ASCII values Given a string as input, write a program to convert the characters of the given string into the hexadecimal equivalent of ASCII values. Examples : Input: GeekOutput: 4765656b Input: IronMan part 3Output :49726f6e4d616e20706172742033 ASCII stands for American Standard Code for Information Interchan 7 min read Convert Hexadecimal value String to ASCII value String Given the Hexadecimal value string as input, the task is to convert the given hexadecimal value string into its corresponding ASCII format string. Examples: Input: 6765656b73Output: geeks Input: 6176656e67657273Output: avengers The âHexadecimalâ or simply âHexâ numbering system uses the Base of 16 6 min read Like