2008-10-15 61 views

回答

22

检查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))); 
+0

已经说过了,并用Attribute.IsDefined代替。 – leppie 2008-10-15 11:22:46