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

249
Views
La llamada es ambigua entre IDictionary<string, object> e IDictionary

Estoy usando una biblioteca con una clase que tiene los siguientes constructores:

 public JobDataMap(IDictionary<string, object> map); public JobDataMap(IDictionary map);

Creé una instancia de JobDataMap:

 var jdm = new JobDataMap(new Dictionary<String, Object> { { "Manager", myObject } });

Pero estoy recibiendo el error de compilación:

 The call is ambiguous between the following methods or properties: 'JobDataMap.JobDataMap(IDictionary<string, object>)' and 'JobDataMap.JobDataMap(IDictionary)'

¿Cómo resolver esto?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puede convertirlo al tipo para el constructor que desea que use:

 var jdm = new JobDataMap((IDictionary<string, object>) new Dictionary<String, Object> { { "Manager", new object() } });

Este diseño parece un poco dudoso, sin embargo...

over 4 years ago · Santiago Trujillo Report

0

Puede hacer cumplir el tipo que se pasa así:

 var jdm = new JobDataMap((IDictionary<string, object>)new Dictionary<String, Object> { { "Manager", myObject } });

O podría hacer un método de fábrica y hacer que el constructor no genérico (supongo que lo usa menos) sea private :

 public class JobDataMap { public JobDataMap(IDictionary<string, object> map) { } private JobDataMap(IDictionary map) { } public static JobDataMap FromNonGenericMap(IDictionary map) { return new JobDataMap(map); } }

Uso:

 var jdm = JobDataMap.FromNonGenericMap(someNonGenericDictionary);

y luego puedes usar el genérico regular así:

 var jdm = new JobDataMap(new Dictionary<String, Object> { { "Manager", myObject } });
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!