Mega Code Archive

 
Categories / C# / Data Types
 

Hex To Int

using System; using System.Globalization; using System.IO; using System.Security.Cryptography; using System.Text; using System.Xml.Serialization; namespace DACU.Tools {   class Utils   {     public static int HexToInt(char h)     {       if ((h >= '0') && (h <= '9'))         return (h - '0');       if ((h >= 'a') && (h <= 'f'))         return ((h - 'a') + 10);       if ((h >= 'A') && (h <= 'F'))         return ((h - 'A') + 10);       return -1;     }   } }