Advertisement
Guest User

Untitled

a guest
May 13th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4.  
  5.  
  6. namespace _06.HexadecimalToBinary
  7. {
  8. class HexadecimalToBinary
  9. {
  10.  
  11. static Dictionary<char, string> hexBin = new Dictionary<char, string>()
  12. {
  13. {'0', "0000"},
  14. {'1', "0001"},
  15. {'2', "0010"},
  16. {'3', "0011"},
  17. {'4', "0100"},
  18. {'5', "0101"},
  19. {'6', "0110"},
  20. {'7', "0111"},
  21. {'8', "1000"},
  22. {'9', "1001"},
  23. {'A', "1010"},
  24. {'B', "1011"},
  25. {'C', "1100"},
  26. {'D', "1101"},
  27. {'E', "1110"},
  28. {'F', "1111"}
  29. };
  30.  
  31.  
  32. static string HexToBin(string hexValue)
  33. {
  34. string binValue = string.Empty;
  35.  
  36. foreach (char hex in hexValue)
  37. {
  38. binValue += hexBin[hex];
  39. }
  40.  
  41. return binValue;
  42. }
  43.  
  44. static void Main()
  45. {
  46. string hexNumber = Console.ReadLine();
  47.  
  48. Console.WriteLine(BigInteger.Parse(HexToBin(hexNumber)));
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement