How do you call a method dynamically?

By axostech

Sounds impossible?

Well actually reflection as it has been called has been around for a while..

public string GetConnectionString() {
object[] results = this.Invoke(“GetConnectionString”, new object[0]);
return ((string)(results[0]));
}

This invokes the method on “this” object called “GetConnectionString()” passing in o as an argument (forced cast to object)

and then returns the results as an object array..

Not for the faint of heart, but well rewarded for the Enterprise Architect..

Leave a Reply