2014/10/08

C#, 클래스의 필드(변수) 정보 가져오기


Type type = typeof(object);

System.Reflection.FieldInfo[] f =
    type.GetFields(System.Reflection.BindingFlags.Public |
        System.Reflection.BindingFlags.Static |
        System.Reflection.BindingFlags.Instance);

foreach(System.Reflection.FieldInfo _f in f) {
    Console.WriteLine(_f.Name + ":" + _f.GetValue(null));
}

# Flags 는 해당 클래스내에 선언된 것중에 가져올 타입 지정




댓글 없음:

댓글 쓰기

가장 많이 본 글