fork download
  1. using System;
  2. using System.Linq;
  3. using System.Reflection;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var derived = new Derived();
  10. var baseType = derived.GetType().BaseType;
  11.  
  12. var classCField = baseType.GetField("_classC", BindingFlags.NonPublic | BindingFlags.Instance);
  13.  
  14. Console.WriteLine(classCField.GetValue((Base)derived));
  15. }
  16. }
  17.  
  18. public class ClassC
  19. {
  20. }
  21.  
  22. public abstract class Base//<A, B> : IBase<A, B> where A : class where B : class, new()
  23. {
  24. private readonly ClassC _classC = new ClassC();
  25. }
  26.  
  27. public class Derived : Base//<ClassC, ClassD>
  28. {
  29. }
Success #stdin #stdout 0.02s 22260KB
stdin
Standard input is empty
stdout
ClassC