2008-10-15 23 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