What are the access-specifiers available in c#?

Answer Posted / md eqbal ansari

C# provide five access specifiers , they are as follows :

public, private , protected , internal and protected
internal .

public :

public is the most common access specifier in C# . It can
be access from anywhere, that means there is no restriction
on accessibility. The scope of the accessibility is inside
class as well as outside. The type or member can be
accessed by any other code in the same assembly or another
assembly that references it.

private :

The scope of the accessibility is limited only inside the
classes or struct in which they are declared. The private
members cannot be accessed outside the class and it is the
least permissive access level.

protected :

The scope of accessibility is limited within the class or
struct and the class derived (Inherited )from this class.

internal :

The internal access modifiers can access within the program
that contain its declarations and also access within the
same assembly level but not from another assembly.

protected internal :

Protected Internal member can be accessed as a Internal
member within the assembly and as a protected member
outside the assembly.

Is This Answer Correct ?    18 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are access modifiers used for?

580


What is event sourcing in c#?

492


What are class fields?

489


How many bytes is an int c#?

479


Is there any sample c# code for simple threading?

552






What is private and shared assembly?

532


Is it good to use var in c#?

451


What is asenumerable in c#?

478


What is the difference between properties and indexer in c#?

426


What is the CTS, and how does it relate to the CLS?

542


What are value types in c#?

492


Explain different properties of object oriented systems.

439


What does int32 mean in c#?

455


What is the use of xmlserializer?

462


What is ienumerable t in c#?

478