Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
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.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

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

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda