Uses reflection to show the inherited members of a class : Reflection Assembly « Development Class « C# / C Sharp






Uses reflection to show the inherited members of a class

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

1.Get Method ParamemtersGet Method Paramemters
2.Get type infomation: base type, is abstract, is com object, is sealed, is classGet type infomation: base type, is abstract, is com object, is sealed, is class
3.Get all methods from a classGet all methods from a class
4.Get all fields from a classGet all fields from a class
5.Get all properties from a classGet all properties from a class
6.Get all implemented interface from a classGet all implemented interface from a class
7.Using reflection to get information about an assembly
8.Demonstrate using Type class to discover information about a classDemonstrate using Type class to discover information about a class
9.Demonstrate dynamically invoking an object
10.Locate an assembly, determine types, and create an object using reflection
11.Utilize MyClass without assuming any prior knowledge
12.Uses reflection to execute a class method indirectlyUses reflection to execute a class method indirectly
13.Deeper Reflection: Invoking Functions
14.Illustrates runtime type invocation
15.Illustrates unloading an application domain
16.Demonstrate typeofDemonstrate typeof
17.Create an object using reflectionCreate an object using reflection
18.Uses an object in another application domain
19.Illustrates creation of an application domainIllustrates creation of an application domain