Use BindingFlags Instance and NonPublic : BindingFlags : Reflection C# Source Code


Custom Search

C# Source Code » Reflection » BindingFlags »

 

Use BindingFlags Instance and NonPublic








    


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.");
    }
}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Reflection
» BindingFlags