PROGRAMMING USING C#
LAB MANUAL
SARASWATHI RAMALINGAM
SRI AKILANDESWARI WOMENS COLLEGE
THIRUVALLUVAR UNIVERSITY
REFLECTION
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace pragim
{
public class MainClass
{
static void Main(string[] args)
{
Type T = Type.GetType("pragim.Customer");
Console.WriteLine("Full Name={0}", T.FullName);
Console.WriteLine("Just The Name={0}", T.Name);
Console.WriteLine("Just The Namespace={0}", T.Namespace);
Console.WriteLine();
Console.WriteLine("Properties in Customer");
PropertyInfo[] properties = T.GetProperties();
foreach (PropertyInfo property in properties)
{
Console.WriteLine(property.PropertyType.Name+" "+property.Name);
}
Console.WriteLine();
Console.WriteLine("Methods in Customer Class");
MethodInfo[] methods = T.GetMethods();
foreach (MethodInfo method in methods)
{
Console.WriteLine(method.ReturnType.Name + " " +method.Name);
}
Console.WriteLine();
Console.WriteLine("Constructor in Customer Class");
ConstructorInfo[] constructors = T.GetConstructors();
foreach (ConstructorInfo constructor in constructors)
{
Console.WriteLine(constructor.ToString());
}
}
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public Customer(int ID, string Name)
{
this.Id = ID;
this.Name = Name;
}
public Customer()
{
this.Id = -1;
this.Name = string.Empty;
}
public void PrintID()
{
Console.WriteLine("ID={0}", this.Id);
}
public void PrintName()
{
Console.WriteLine("NAME={0}", this.Name);
}
}
}
OUTPUT

PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM

  • 1.
    PROGRAMMING USING C# LABMANUAL SARASWATHI RAMALINGAM SRI AKILANDESWARI WOMENS COLLEGE THIRUVALLUVAR UNIVERSITY
  • 2.
    REFLECTION using System; using System.Collections.Generic; usingSystem.Linq; using System.Text; using System.Reflection; namespace pragim { public class MainClass { static void Main(string[] args) { Type T = Type.GetType("pragim.Customer"); Console.WriteLine("Full Name={0}", T.FullName); Console.WriteLine("Just The Name={0}", T.Name); Console.WriteLine("Just The Namespace={0}", T.Namespace); Console.WriteLine();
  • 3.
    Console.WriteLine("Properties in Customer"); PropertyInfo[]properties = T.GetProperties(); foreach (PropertyInfo property in properties) { Console.WriteLine(property.PropertyType.Name+" "+property.Name); } Console.WriteLine(); Console.WriteLine("Methods in Customer Class"); MethodInfo[] methods = T.GetMethods(); foreach (MethodInfo method in methods) { Console.WriteLine(method.ReturnType.Name + " " +method.Name); } Console.WriteLine(); Console.WriteLine("Constructor in Customer Class"); ConstructorInfo[] constructors = T.GetConstructors(); foreach (ConstructorInfo constructor in constructors) { Console.WriteLine(constructor.ToString()); } } }
  • 4.
    public class Customer { publicint Id { get; set; } public string Name { get; set; } public Customer(int ID, string Name) { this.Id = ID; this.Name = Name; } public Customer() { this.Id = -1; this.Name = string.Empty; } public void PrintID() { Console.WriteLine("ID={0}", this.Id); } public void PrintName() { Console.WriteLine("NAME={0}", this.Name); } } }
  • 5.