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

104
Views
Reflection in .NET
class Program
{
    static void Main(string[] args)
    {
        Type doub = typeof(Doub);
        object result = doub.InvokeMember("Call", BindingFlags.InvokeMethod, null, null, new object[] { });
    }
}

public class Doub
{
    public Collection<string> Call()
    {
        Collection<string> collection = new Collection<string>();
        return collection;
    }

    public Collection<T> Call<T>()
    {
        Collection<T> collection = new Collection<T>();
        return collection;
    }
}

I tried to call the Call method, but the program cannot figure out which method to call. Error: (System.Reflection.AmbiguousMatchException: "Ambiguous match found). How can you call exactly the Call() method of the class?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to use a different way to get the method to execute. For example, the Type object has a method called GetMethod with various overloads, you could use the one that allows you to specify how many generic parameters the method has, for example:

Type doub = typeof(Doub);
var callMethod = doub.GetMethod("Call", 0, new Type[] {});

// You need an instance of the object to call the method on
var x = new Doub();

var result = callMethod.Invoke(x, new object[] {});
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!