Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between access specifier protected and internal protected in C#

What is the difference between access specifier protected and internal protected in C# ?

like image 510
user422560 Avatar asked Aug 17 '10 07:08

user422560


1 Answers

Internal can be seen within the assembly.

Protected can be seen by classes inheriting from the class where it is defined.

Protected internal can be seen within the assembly OR types derived from the class where it is defined (including types from other assemblies).

See: http://msdn.microsoft.com/en-us/library/ba0a1yw2.aspx

Copied from the page:

public              Access is not restricted.
protected           Access is limited to the containing class or types derived from the containing class.
internal            Access is limited to the current assembly.
protected internal  Access is limited to the current assembly or types derived from the containing class.
private             Access is limited to the containing type.
like image 178
Lasse Espeholt Avatar answered Sep 22 '22 12:09

Lasse Espeholt