How to dynamically call a method in C#? [duplicate]

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)