Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
VS 2017 Bug or new features?

After upgrading to VS 2017 I got the following error from this code (which has always been working perfectly)

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;
    }

Exception:

Error 1: The variable 'i' cannot be used with type arguments
Error 2: 'hex' is a variable but is used like a type    

the solution was to surround the expression by parentheses.

for (int i = 0; i < (hex.Length >> 1); ++i)

But that made me wonder is this a bug or a new functionality? Thanks.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Thanks for reporting this. This is a confirmed regression in the precedence of parsing. This fix will ship in the first quarterly release of VS2017 at the latest.

Information on the fix: https://github.com/dotnet/roslyn/pull/16834

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda