fork download
  1. using System;
  2.  
  3. public class Base
  4. {
  5. protected int Count { get { return 1; } }
  6. }
  7.  
  8. public class Derived : Base
  9. {
  10. public new int Count { get { return base.Count; } }
  11.  
  12. }
  13.  
  14. public class Test
  15. {
  16. public static void Main()
  17. {
  18. Base b = new Derived();
  19. Console.WriteLine(b.Count);
  20. }
  21. }
Compilation error #stdin compilation error #stdout 0.02s 23192KB
stdin
Standard input is empty
compilation info
prog.cs(19,23): error CS1540: Cannot access protected member `Base.Count' via a qualifier of type `Base'. The qualifier must be of type `Test' or derived from it
prog.cs(5,16): (Location of the symbol related to previous error)
prog.cs(19,23): error CS0122: `Base.Count.get' is inaccessible due to its protection level
prog.cs(5,24): (Location of the symbol related to previous error)
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty