升级到VS 2017后,我从此代码中得到以下错误(一直运行良好)
byte[] HexStringToByteArray(string hex)
{
if (hex.Length % 2 == 1)
throw new Exception("The binary key cannot have an odd number of digits");
byte[] arr = new byte[hex.Length >> 1];
for (int i = 0; i < hex.Length >> 1; ++i) // Error in this line
{
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
}
return arr;
}
Run Code Online (Sandbox Code Playgroud)
例外:
Error 1: The variable 'i' cannot be used with type arguments
Error 2: 'hex' …Run Code Online (Sandbox Code Playgroud)