Mega Code Archive

 
Categories / C# / Reflection
 

Type GetProperties

//ReflectionTest using System; using System.Reflection; public class Class1 {     public static int Main() {         Type t = typeof(MyClass);         Console.WriteLine("Type of class: " + t);         Console.WriteLine("Namespace: " + t.Namespace);         ConstructorInfo[] ci = t.GetConstructors();         PropertyInfo[] pi = t.GetProperties();         Console.WriteLine("Properties are:");         foreach (PropertyInfo i in pi) {             Console.WriteLine(i);         }         return 0;     }     public class MyClass {         public int pubInteger;         private int _privValue;         public MyClass() {         }         public MyClass(int IntegerValueIn) {             pubInteger = IntegerValueIn;         }         public int Add10(int IntegerValueIn) {             Console.WriteLine(IntegerValueIn);             return IntegerValueIn + 10;         }         public int TestProperty {             get {                 return _privValue;             }             set {                 _privValue = value;             }         }     } }