![](/img/trans.png)
[英]Invoke a method using reflection with the “params” keyword without arguments
[英].net reflection and the “params” keyword
在.net中,有没有办法使用反射来确定方法上的参数是否用“params”关键字标记?
检查ParamArrayAttribute
是否已应用于ParameterInfo
对象:
//use string.Format(str, args) as a test
var method = typeof(string).GetMethod("Format", new[] {typeof(string), typeof(object[])});
var param = method.GetParameters()[1];
Console.WriteLine(Attribute.IsDefined(param, typeof(ParamArrayAttribute)));
测试以查看最终的ParameterInfo是否已将ParamArrayAttribute应用于它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.