I have a method:
add(int x,int y)
I also have:
int a = 5;
int b = 6;
string s = \"add\";
Is it poss
how can i do this in c#?
Using reflection.
add
has to be a member of some type, so (cutting out a lot of detail):
typeof(MyType).GetMethod("add").Invoke(null, new [] {arg1, arg2})
This assumes add
is static (otherwise first argument to Invoke
is the object) and I don't need extra parameters to uniquely identify the method in the GetMethod
call.