Open
Description
The docs describe the types
parameter as follows:
An array of Type objects representing the number, order, and type of the parameters for the method to get.
This implies that the parameter types should match exactly, but that is not the case. For example, given:
class MyClass { public void Foo (MyClass obj) { } }
class MySubClass : MyClass { }
The call typeof(MyClass).GetMethod("Foo", new[] { typeof(MySubClass) })
will actually match Foo (MyClass obj)
.
It looks like the behavior is more like "match the most specific method that can be invoked with the provided parameters".
So in the above case, since Foo (MyClass obj)
can be called with a MySubClass
parameter, it will also be matched.