Advertisement
Ham62

shittyHex2Dec.cs

Jan 21st, 2020
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1.         static String[] table = new string[] {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
  2.         static int hexToDec(String hex)
  3.         {
  4.             int dec=0;
  5.  
  6.             for(int i = 0; i <hex.Length; i++)
  7.                 dec += Array.IndexOf(table, hex[i]+"") * (int)Math.Pow(16, hex.Length - i - 1);
  8.  
  9.             return dec;
  10.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement