mercredi 15 juillet 2015

Can you invoke a method of an object using a string? [duplicate]

This question already has an answer here:

For example:

Process[] processes = Process.GetProcesses();
string method = "Refresh";
foreach(Process p in processes)
{
    p.Invoke(method); //I know there isn't a method named Invoke in the Process class
}

Is there a way I can invoke a method this way using reflection?





Aucun commentaire:

Enregistrer un commentaire