samedi 27 avril 2019

How do I use reflection to call a non public method with 0 arguments? [duplicate]

This question already has an answer here:

My class has two methods that look like this:

void Update()
void Update(string)

With reflection, I want to call the top one, but when I try this:

            const BindingFlags findFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;

            var methodInfo = script.GetType().GetMethod(methodName, findFlags);

I get a AmbiguousMatchException. How do I call the no arg method?





Aucun commentaire:

Enregistrer un commentaire