Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Convert a hexadecimal number to decimal number

C# Sharp Basic: Exercise-30 with Solution

Write a C# program to convert a hexadecimal number to decimal number.

C# Sharp Exercises: Convert a hexadecimal number to decimal number

Sample Solution:-

C# Sharp Code:

using System;
using System.Collections.Generic;
public class Exercise30 {
 public static void Main() {
      
     string hexval = "4B0";
     Console.WriteLine("Hexadecimal number: "+hexval);
     int decValue = int.Parse(hexval, System.Globalization.NumberStyles.HexNumber);
     Console.WriteLine("Convert to-");
     Console.WriteLine("Decimal number: "+decValue);
   }
}

Sample Output:

Hexadecimal number: 4B0                                                
Convert to-                                                            
Decimal number: 1200 

Flowchart:

Flowchart: C# Sharp Exercises - Convert a hexadecimal number to decimal number

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# program to find the size of a specified file in bytes.
Next: Write a C# program to multiply corresponding elements of two arrays of integers.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.