1/**
2 * Copyright(C) 2004
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 2004.
11 * @authorĀ : Salih Yurttas, Yi Yang.
12 */
13
14
15using System;
16using System.Reflection;
17
18namespace Reflection00
19{
20
21 public class R00
22 {
23 public static int Main(string[] args)
24 {
25 //get class/namespace information
26 Type e = typeof(Employee);
27 Console.WriteLine("Type of class: " + e);
28 Console.WriteLine("Namespace: " + e.Namespace);
29
30 //get constructor information
31 ConstructorInfo[] ci = e.GetConstructors();
32 Console.WriteLine("Constructors are:");
33 foreach(ConstructorInfo i in ci)
34 Console.WriteLine(i);
35
36 //get property information
37 PropertyInfo[] pi = e.GetProperties();
38 Console.WriteLine("Properties are:");
39 foreach(PropertyInfo i in pi)
40 Console.WriteLine(i);
41
42 //get method information
43 MethodInfo[] mis = e.GetMethods();
44 Console.WriteLine("Methods are:");
45 foreach(MethodInfo mi in mis)
46 {
47 Console.WriteLine("Name: " + mi.Name);
48 ParameterInfo[] pif = mi.GetParameters();
49 foreach(ParameterInfo p in pif)
50 Console.WriteLine("Type: " +
51 p.ParameterType +
52 " parameter name: " +
53 p.Name);
54 }
55 return 0;
56 }
57 }
58
59 public class Employee
60 {
61 private string name;
62 private string gender;
63
64 public string Name
65 {
66 get
67 {
68 return name;
69 }
70 set
71 {
72 name = value;
73 }
74 }
75
76 public string Gender
77 {
78 get
79 {
80 return gender;
81 }
82 set
83 {
84 gender = value;
85 }
86 }
87
88 public Employee()
89 {
90 }
91
92 public Employee(string name,
93 string gender)
94 {
95 Name = name;
96 Gender = gender;
97 }
98
99 public void Done()
100 {
101 Console.WriteLine("I'm done!");
102 }
103 }
104
105}