Posted by : Sudhir Chekuri Tuesday, 5 January 2016

Access specifiers are used to define scope of a type as well as its members ie.,who can access it and who can't access it.
C#.NET supports five different access specifiers. They are:
1)Private
2)Public
3)Protected
4)Internal
5)Protected Internal

Default access specifier of method is private.
Default access specifier of class is internal.

Private

Members declared as private cannot be accessed outside the block.
Members declared as private within class or structure aren't possible outside of them in which they are defined.
In C# the default scope for members of a class or structure is "Private".

Public

Members declared as public can be accessed from anywhere.

Protected

Members declared as protected can be accessed only in the inherited classes

Internal

Members declare as internal can be used only with in the project.
Members which are declared as internal were accessible only with in the project both from child or non-child classes.
The default scope for class is Internal.

Protected Internal

Members declared as Protected Internal, enjoy dual scope ie., Internal and Protected.
Within the project they behave as internal, providing access to all other classes.
Outside the project they behave as Protected, and still provide access to child classes

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -