samedi 6 juillet 2019

C# GetMethod vs GetRuntimeMethod

I am using GetRuntimeMethod to get a method out of type. Everything works fine but I have noticed that there is a GetMethod. What is the difference between the two?

this.target.GetType().GetRuntimeMethod(
    "MethodName",
    new System.Type[0]
)?.Invoke(targetObject, null);

From the names I can only guess that GetRuntimeMethod works while the program is running. And GetMethod works during program compilation?

Are there any advantages of using one instead of another? (This last question can be deductible from the answer to what is the difference between the two of course)





Aucun commentaire:

Enregistrer un commentaire