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

349
Vistas
The type arguments for method The type arguments for method `System.MemoryExtensions.Reverse<T>(this System.Span<T>)' cannot be inferred from the usag

Why does my code come up with this error? I'm trying to solve the second question on Coderbyte, it's about reversing a string.

Error:

Main.cs(8,39): error CS0411: The type arguments for method `System.MemoryExtensions.Reverse<T>(this System.Span<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly

Code:

using System;

class MainClass {

  public static string FirstReverse(string str) {

    
    string backwards = new string(str.Reverse().ToArray());
    return backwards;
  }

  static void Main() {  
    Console.WriteLine(FirstReverse(Console.ReadLine()));
  } 

}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

String (https://docs.microsoft.com/en-us/dotnet/api/system.string?view=net-5.0) does not have a method Reverse, so the only thing to resolve Reverse to is a static extension method available with the using directives in your program. From System the best the compiler could do is System.MemoryExtensions.Reverse<T>(this System.Span<T>) but it couldn't use this because String is not a Span<T> for any T.

You were probably looking for Enumerable.Reverse<T> (https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.reverse?view=net-5.0) because String is an IEnumerable<char>. To use this you will need to include it with using System.Linq;

over 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