internal static byte[] FromBinHexString(string value) { char[] array = value.ToCharArray(); byte[] array2 = new byte[array.Length / 2 + array.Length % 2]; int num = array.Length; if (num % 2 != 0) { throw SoapHexBinary.CreateInvalidValueException(value); } int num2 = 0; for (int i = 0; i < num - 1; i += 2) { array2[num2] = SoapHexBinary.FromHex(array[i], value); byte[] array3 = array2; int num3 = num2; array3[num3] = (byte)(array3[num3] << 4); byte[] array4 = array2; int num4 = num2; array4[num4] += SoapHexBinary.FromHex(array[i + 1], value); num2++; } return(array2); }
private static byte FromHex(char hexDigit, string value) { byte result; try { result = byte.Parse(hexDigit.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture); } catch (FormatException) { throw SoapHexBinary.CreateInvalidValueException(value); } return(result); }