Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# public interface vs interface

Is there any difference betwen public interface declaration and interface? (I thought that interfaces are public by default).

I am asking because VS2012 is whining about access levels.

I have declared:

interface Ixyz
{nothing important here}

and property (in another class who is using Ixhz as its type):

public Ixhz Somename
{nothing important here}

And when I try to compile the project, it whines about access levels but when I declare interface like public interface Ixyz it stops doing it. Are there any consequences of adding public to interface?

like image 838
user2184057 Avatar asked Apr 13 '26 10:04

user2184057


1 Answers

Members in interfaces are always public, and in fact cannot have access modifiers.

Interfaces themselves have the same default access level as other types.

Specifically, top-level types are internal by default, and nested types are private by default.

like image 121
SLaks Avatar answered Apr 15 '26 00:04

SLaks