Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
Discrepancia en el recuento de parámetros en property.GetValue()

estoy consiguiendo el

discrepancia en el conteo de parámetros

error. Ocurre en la cláusula if . Mi código:

 private Dictionary<string,string> ObjectToDict(Dictionary<string, string> dict, object obj) { var properties = obj.GetType().GetProperties(); foreach (var property in properties) { if (property.GetValue(obj, null) != null) dict["{{" + property.Name + "}}"] = property.GetValue(obj, null).ToString(); } return dict; }

Es extraño porque funciona bien cuando agrego el valor de la property al diccionario, pero no cuando pruebo si es null en la cláusula if .

Todas las preguntas que encontré estaban poniendo una cantidad incorrecta de argumentos en la llamada a la función, pero AFAIK no hay nada diferente entre mis dos llamadas.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Estoy bastante seguro de que esto se debe a que su tipo de objeto tiene una propiedad indexada y está pasando nulo al parámetro de índice en la llamada GetValue .

Quite la propiedad indexada o filtre las propiedades indexadas de su variable de propiedades , por ejemplo:

 var properties = obj.GetType().GetProperties() .Where(p => p.GetIndexParameters().Length == 0);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!