通过反射获取方法失败

Luc*_*uca 2 c# reflection overloading

我有以下方法由Gl推出:

public static void Get(int pname, out int @params)
Run Code Online (Sandbox Code Playgroud)

我试图通过以下方式使用反射来获取它:

MethodInfo mGetMethod = typeof(Gl).GetMethod("Get",
                                             BindingFlags.Public|BindingFlags.Static,
                                             null, 
                                             new Type[] 
                                             { 
                                                 typeof(Int32), 
                                                 typeof(Int32) 
                                             }, 
                                             null);
Run Code Online (Sandbox Code Playgroud)

但我没有成功.为什么?

是因为out关键字?

Isa*_*ker 7

使用typeof(Int32).MakeByRefType()你的第二个参数.即:

MethodInfo mGetMethod = typeof(Gl).GetMethod("Get", bindingFlags.Public|BindingFlags.Static, null, new Type[] { typeof(Int32), typeof(Int32).MakeByRefType() }, null);
Run Code Online (Sandbox Code Playgroud)