mardi 4 juin 2019

Is there any way to protected a method from reflection?

Say you have a method with the signature:

public class Class
{
    private void ThisShouldOnlyBeUsedByMe()
    {
        . . .
    }
}

you can call this method via reflection by just doing typeof(Class).GetMethod("ThisShouldOnlyBeUsedByMe", flags).Invoke(instance, null); but, is there any way to prevent this?





Aucun commentaire:

Enregistrer un commentaire