fork(3) download
  1. using System;
  2.  
  3. class foo {
  4. public string _public = "a";
  5. protected string _protected = "protected";
  6. }
  7.  
  8. class bar: foo {
  9.  
  10. }
  11.  
  12. class kid: foo {
  13. public void test() {
  14. foo b = new bar();
  15. Console.WriteLine(b._public);
  16. Console.WriteLine(b._protected);
  17. }
  18. }
  19.  
  20. public class Test
  21. {
  22. public static void Main()
  23. {
  24. kid k = new kid();
  25. k.test();
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(16,23): error CS1540: Cannot access protected member `foo._protected' via a qualifier of type `foo'. The qualifier must be of type `kid' or derived from it
prog.cs(5,19): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty