Search code examples
c#javatranslationpublic-method

Java2C# translation: public methods in Interfaces in C#


Another translation question, this may be more theoretical, but I am curious as to the design choice. SFNQ:

Why does C# not allow controlling for controlling access to methods in interfaces like Java does? For example, in a C# interface:

   public void Visit(Axiom axiom);

Thank you.


Solution

  • In both C# and Java, all methods on an interface are public.

    In Java, the public keyword is allowed, likely to save on parsing rules. In C#, the public keyword was considered redundant and was removed from interface declarations altogether.