Mega Code Archive

 
Categories / C# / Reflection
 

Get an array of all the index parameters for the property

using System; using System.Reflection; public class MyProperty    {     private string caption = "A Default caption";     public string Caption     {         get{return caption;}         set {if(caption!=value) {caption = value;}         }     } } class Mypropertyinfo {     public static int Main()     {         Type t = Type.GetType("MyProperty");         PropertyInfo pi = t.GetProperty("Caption");         ParameterInfo[] parms = pi.GetIndexParameters();         Console.WriteLine("\r\n" + t.FullName + "." + pi.Name+ " has " + parms.GetLength(0) + " parameters.");         return 0;     } }