Mega Code Archive

 
Categories / C# / Reflection
 

Gets the type of this property

using System; using System.Reflection;     public class Example     {         public int Answer                 {             get             {                 return 42;             }         }         public static void Main()         {             Type t = typeof(Example);             PropertyInfo pi = t.GetProperty("Answer");             Console.WriteLine("The return type of the {0}.{1} property is {2}.",                 t.Name, pi.Name, pi.PropertyType);         }     }