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

127
Vistas
Can anyone help me with sort fuctions written in Javascript to C# or explain me how these lines of code work

I'm trying to transtate this Javascript function to C# method.

parametrize = (obj, join = false) ->
    arrayOfArrays = _.pairs(obj).sort()

    symbol = if join then '&' else ''

    sortedParams = ''
    _.each arrayOfArrays, (value) ->
      sortedParams += "#{_.first(value)}=#{_.last(value)}" + symbol

    return sortedParams

This functions is written base on these scenarios.

  • parameters are sorted lexicographically by keys;
  • parameters are joined in the format key=value;
  • sig = MD5(parameters_value + session_secret_key);
  • the sig value is changed to the lower case.

I would like to write this function in C# and because of lack of understanding of what javascript does. If anyone could help me explaining what Javascript functions do for example would be awesome.

Thank you :)

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

0

So, in terms of understanding the JavaScript, the method just combines an object containing key-value pairs and combines them into a single string with either a space between or an ampersand. I'm assuming this method is used to send parameters with a get or post request, or with spaces for command line arguments.

// method that accepts an object and a join boolean (false by default)
parametrize = (obj, join = false) ->

// sort the obects and store as an array
arrayOfArrays = _.pairs(obj).sort()

// decide which join character to use
symbol = if join then '&' else ''

// Create the variable to return
sortedParams = ''

// loop through each of the array rows 
_.each arrayOfArrays, (value) ->
  // add each row into the string and add the joining symbol
  sortedParams += "#{_.first(value)}=#{_.last(value)}" + symbol

// Once complete, return the created string
return sortedParams

As for the c# side of things, this is all fairly rudimentary stuff. A quick google on loops, strings (including concatenation) and methods will sort you out.

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