小编Mhd*_*een的帖子

VS 2017 Bug或新功能?

升级到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)

c# roslyn c#-7.0

24
推荐指数
1
解决办法
678
查看次数

标签 统计

c# ×1

c#-7.0 ×1

roslyn ×1