Uses reflection to show the inherited members of a class
/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa
Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/
// Reflect.cs -- Uses reflection to show the inherited members of a class.
//
// Compile this program with the following command line:
// C:>csc Reflect.cs
//
using System;
using System.Reflection;
namespace nsReflect
{
class clsReflection
{
private double pi = 3.14159;
public double Pi
{
get {return (pi);}
}
public string ShowPi ()
{
return ("Pi = " + pi);
}
}
public class Reflection
{
static public void Main ()
{
clsReflection refl = new clsReflection ();
Type t = refl.GetType();
Console.WriteLine ("The type of t is " + t.ToString());
MemberInfo [] members = t.GetMembers();
Console.WriteLine ("The members of t are:");
foreach (MemberInfo m in members)
Console.WriteLine (" " + m);
}
}
}
Related examples in the same category