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

138
Vistas
Passing Arrays to blazors IJSRuntime.InvokeAsync

I wonder what is the best way to pass an array to IJSRuntime.InvokeAsync.
The problem I stumbled upon is that blazor will pass each element of the array as a parameter to the javascript function since InvokeAsync has an open parameter list and will not know if you just passed arguments of the same type or an array.

For now I just go with a second parameter like InvokeAsync("functionname", array, false).

Any other suggestions? Better solutions?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You'd either have to cast your array to object* or call the Extension method directly:

var array = Array.Empty<Baz>();
// Casting to object
JS.InvokeAsync<Foo>("bar", (object)array);

// Explicitly call the extension method:
JSRuntimeExtensions.InvokeAsync<Foo>(JS, "bar", array);

Or just use the overload it thinks you are attempting to call:

JS.InvokeAsync<Foo>("bar", new object[] { array });

* Based on my limited knowledge of C#'s Overload Resolution.

about 4 years ago · Juan Pablo Isaza 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