samedi 19 décembre 2020

Calling a function from another namespace from a string C#

I know in C# you can call a function from a string by doing so

Type thisType = this.GetType();
MethodInfo theMethod = thisType.GetMethod(TheCommandString);
theMethod.Invoke(this, userParameters);

But I would like something like this

CallMethodFromName("Console.WriteLine", "Hello, world!");

How do I call a function from another namespace using reflection ?





Aucun commentaire:

Enregistrer un commentaire