How to use Reflection to Invoke an Overloaded Method in .NET

前端 未结 3 1509
無奈伤痛
無奈伤痛 2020-12-08 03:46

Is there a way to Invoke an overloaded method using reflection in .NET (2.0). I have an application that dynamically instantiates classes that have been derived from a comm

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 04:22

    Use the GetMethod overload that takes a System.Type[], and pass an empty Type[];

    typeof ( Class ).GetMethod ( "Method", new Type [ 0 ] { } ).Invoke ( instance, null );
    

提交回复
热议问题