private static int GetHexVal(char hex) { int val = (int)hex; return val - (val < 58 ? 48 : (val < 97 ? 55 : 87)); } }