指定OUT参数,为Type.GetMethod [英] Specifying out params for Type.GetMethod
本文介绍了指定OUT参数,为Type.GetMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用反射的方法的TryParse信息获取(给予好评的第一人猜测为什么;)
I'm using reflection to get at the TryParse method info (upvote for the first person to guess why ;).
如果我称之为:
typeof(Int32).GetMethod("Parse",
BindingFlags.Static | BindingFlags.Public,
null,
new Type[] { typeof(string) },
null);
我得到一个方法回来,但延长这种略带:
I get a method back, but extending this slightly:
typeof(Int32).GetMethod("TryParse",
BindingFlags.Static | BindingFlags.Public,
null,
new Type[] { typeof(string), typeof(Int32) },
null);
我什么也没有回来。我spidersense告诉我这是因为第二个参数是一个输出参数。
I get nothing back. My spidersense is telling me it's because the second parameter is an out parameter.
任何人都知道我做了什么错在这里?
Anyone know what I've done wrong here?
推荐答案
试试这个
typeof(Int32).GetMethod("TryParse",
BindingFlags.Static | BindingFlags.Public,
null,
new Type[] { typeof(string), typeof(Int32).MakeByRefType() },
null);
这篇关于指定OUT参数,为Type.GetMethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文