BindingFlags.Instance : BindingFlags « System.Reflection « C# / C Sharp by API






BindingFlags.Instance

 

using System;
using System.Reflection;

class DumpType {
    public static void Main() {
        MyClass zObj = new MyClass();
        Type tObj = zObj.GetType();
        MemberInfo[] members = tObj.GetMembers(BindingFlags.Instance | BindingFlags.NonPublic);
        foreach (MemberInfo member in members) {
            Console.WriteLine(member.Name);
        }
        members = tObj.GetMembers(BindingFlags.Public | BindingFlags.Static);

        Console.WriteLine(" ");
        foreach (MemberInfo member in members) {
            Console.WriteLine(member.Name);
        }
    }
}

class MyClass {
    private int vara = 5;
    public int PropA {
        get {
            return vara;
        }
    }
    static public void MethodA() {
        Console.WriteLine("MyClass::MethodA called.");
    }
}

   
  








Related examples in the same category

1.BindingFlags.DeclaredOnly