Monday, December 31, 2012

Difference between Internal, Protected and Protected Internal in c#?


Internal – 

Class member can be accessible within the assembly either through object or in a derived class. Not outside the assembly.

Protected – 

Class member can be accessible in a derived class within the assembly and outside the assembly also.

Protected Internal – 

Class member can be accessible within the assembly either through creating object or in a derived class. And Accessible outside the assembly in a derived class only.

Protected Internal means Protected or Internal.

Default access modifier for a class in c#?


Default access modifier for a class is – Internal

Class ABC
{

}

is equivalent to
Internal Class ABC
{

}

Default access modifier for a struct is – Internal
Default access modifier for an Interface is – Public
Default access modifier for a enum is – Public
Default access modifier for a Method is – Private
Default access modifier for a Fields is – Private
Default access modifier for a Property is – Private