Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public);
- PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
- class B
- {
- public int MyProperty { get; set; }
- }
- class C : B
- {
- public string MyProperty2 { get; set; }
- }
- static void Main(string[] args)
- {
- PropertyInfo[] info = new C().GetType().GetProperties();
- foreach (var pi in info)
- {
- Console.WriteLine(pi.Name);
- }
- }
- Type.BaseType
- Type type = obj.GetType();
- PropertyInfo[] info = type.GetProperties(BindingFlags.Public);
- PropertyInfo[] baseProps = type.BaseType.GetProperties(BindingFlags.Public);
- TypeDescriptor.GetProperties(obj);
- foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(obj))
- {
- Console.WriteLine("{0}={1}", prop.Name, prop.GetValue(obj));
- }
Add Comment
Please, Sign In to add comment