fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. class BaseEntity {
  7. public int PropZero {get;set;}
  8. }
  9. class DerivedOne : BaseEntity {
  10. public int PropOne {get;set;}
  11. }
  12. class DerivedTwo : BaseEntity {
  13. public int PropTwo {get;set;}
  14. }
  15. public static void Main()
  16. {
  17. var list = new List<BaseEntity> {
  18. new DerivedOne(), new DerivedTwo()
  19. };
  20. foreach (var e in list) {
  21. var type = e.GetType();
  22. Console.WriteLine("====== {0}", type.FullName);
  23. foreach (var p in type.GetProperties()) {
  24. Console.WriteLine(p);
  25. }
  26. }
  27. }
  28. }
Success #stdin #stdout 0.03s 33872KB
stdin
Standard input is empty
stdout
====== Test+DerivedOne
System.Int32 PropOne
System.Int32 PropZero
====== Test+DerivedTwo
System.Int32 PropTwo
System.Int32 PropZero