Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- namespace Hexadecimal_to_Decimal_Number
- {
- class HexadecimalToDecimalNumber
- {
- public static void Main(string[] args)
- {
- string hex = Console.ReadLine();
- BigInteger dec = 0;
- int power = 1;
- for(int i = hex.Length - 1; i >= 0; i--)
- {
- int num;
- switch (hex[i])
- {
- case 'A': num = 10; break;
- case 'B': num = 11; break;
- case 'C': num = 12; break;
- case 'D': num = 13; break;
- case 'E': num = 14; break;
- case 'F': num = 15; break;
- default: num = (int)hex[i] - 48; break;
- }
- dec += num * power;
- power *= 16;
- }
- Console.WriteLine(dec);
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment