Reflecting and Invoking Members

The GetMembers method returns the members of a type.

Consider the following class:

using System;
using System.Reflection;
using System.Collections.Generic;

class MyClass
    private bool v;
    public void MyValue() { v = true; }

class Program

    static void Main()
        //We can reflect on its public members as follows:
        MemberInfo[] members = typeof(MyClass).GetMembers();
        foreach (MemberInfo m in members) {

The output:

Void MyValue()
System.String ToString()
Boolean Equals(System.Object)
Int32 GetHashCode()
System.Type GetType()
Void .ctor()  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.