Advertisement
YavorGrancharov

Variable_in_Hexadecimal_Format

Jun 10th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Variable_in_Hexadecimal_Format
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string input = Console.ReadLine();
  15.  
  16.             int n;
  17.             if (input.StartsWith("0x"))
  18.             {
  19.                 n = Int32.Parse(input.Substring(2), NumberStyles.HexNumber);
  20.             }
  21.             else
  22.             {
  23.                 n = Int32.Parse(input);
  24.             }
  25.             Console.WriteLine(n);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement