Mega Code Archive

 
Categories / C# / Reflection
 

Determines whether any custom attributes are applied to a method parameter

using System;     using System.Reflection;     public class TestClass      {         public void Method1(params String[] args)         {}     }     public class DemoClass      {         static void Main(string[] args)          {             Type clsType = typeof(TestClass);             MethodInfo mInfo = clsType.GetMethod("Method1");             ParameterInfo[] pInfo = mInfo.GetParameters();             if (pInfo != null)              {                 bool isDef = Attribute.IsDefined(pInfo[0], typeof(ParamArrayAttribute));                 Console.WriteLine(isDef );             }         }     }