lundi 27 juin 2016

Passing parameters dynamically into Method.Invoke

I have methods in a class

public class ReflectionClass {
    public int add(int a, int b) {
        return a + b;
    }
    public int add(int a, int b, int c) {
        return a + b + c;
    }
    public String concatenate (String a, String b, String c){
        return a + b + c;
    }
}

I'm trying to call these methods through reflection. All I have in hand are - the method name and the parameters. Is there a way to pass the parameters into the Method.Invoke() method dynamically based on the number/type of parameters I have in hand?





Aucun commentaire:

Enregistrer un commentaire