fork download
  1. using System;
  2.  
  3. class Interfaces
  4. {
  5.  
  6. public interface IDrawToScreen
  7. {
  8. void Draw();
  9. }
  10.  
  11. public interface IDrawToPrinter
  12. {
  13. void Draw();
  14. }
  15.  
  16. class Circle: IDrawToPrinter, IDrawToScreen
  17. {
  18. public void IDrawToPrinter.Draw() // without public!
  19. {
  20. Console.WriteLine("Draw to printer");
  21. }
  22.  
  23. public void IDrawToScreen.Draw()
  24. {
  25. Console.WriteLine("Draw to screen");
  26. }
  27. /*public void Draw() {
  28. Console.WriteLine("Draaaww");
  29. }*/
  30. }
  31.  
  32. static void Main()
  33. {
  34. Circle c = new Circle();
  35. (c as IDrawToPrinter).Draw();
  36. (c as IDrawToScreen).Draw();
  37. }
  38. }
  39.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(18,30): error CS0106: The modifier `public' is not valid for this item
prog.cs(23,29): error CS0106: The modifier `public' is not valid for this item
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty