/* This Example is a part of different * examples shown in Book: * C#2005 Beginners: A Step Ahead* Written by: Gaurav Arora * Reach at : msdotnetheaven*/// File name : reflectionAssembly.csusing System;using System.Reflection;namespace CSharp.AStepAhead.reflectionAssembly{ public class reflectionAssembly { public static void Main() { Type myType = typeof(aClassToTest); Console.Clear(); Console.WriteLine("\nType of class: " + myType); Console.WriteLine("Namespace: " + myType.Namespace); ConstructorInfo[] ci = myType.GetConstructors(); Console.WriteLine("\n-----------------------------------------------"); Console.WriteLine("Constructors are:"); foreach (ConstructorInfo i in ci) { Console.WriteLine(i); } PropertyInfo[] pi = myType.GetProperties(); Console.WriteLine("\n-----------------------------------------------"); Console.WriteLine("Properties are:"); foreach (PropertyInfo i in pi) { Console.WriteLine(i); } MethodInfo[] mi = myType.GetMethods(); Console.WriteLine("\n-----------------------------------------------"); Console.WriteLine("Methods are:"); foreach (MethodInfo i in mi) { Console.WriteLine("\nName: " + i.Name); ParameterInfo[] pif = i.GetParameters(); foreach (ParameterInfo p in pif) { Console.WriteLine(" Type: " + p.ParameterType + " parameter name: " + p.Name); } } Console.ReadLine(); } public class aClassToTest { public int pubInteger; private int _privValue; public aClassToTest() { //Blank construtor } public aClassToTest(int newIntValue) { pubInteger = newIntValue; } public int Add(int num1, int num2) { return num1 + num2; } public int Substract(int num1, int num2) { return num1 - num2; } public int Multiply(int num1, int num2) { return num1 * num2; } public int privValue { get { return _privValue; } set { _privValue = value; } } } }}