Dynamically Call A Method, Using a String with Method Name

I was trying to set up a dynamic setup of algorithms in server side code which return true if they succeed, but I wanted users to be able to choose from a database generated list as to which algorithm they wished to run, unfortunately I wanted to be able to update the list dynamically without having to rebuild all the code, only the algorithm static class that contains the algorithm and the database that contains the names of all the classes but not modify the presentation layer.

After having a quick look around I found this code on an old faithful website codeproject.com with the perfect article which contained a simple solution to my problem.

Dynamically Invoke A Method, Given Strings with Method Name and Class Name by Matt Perdeck.

The solution I had only required some minor modification to make it work for me,

and to call it

Leave a Reply

Your email address will not be published. Required fields are marked *