Access modifiers or specifiers defines the scope of accessibility of a class members.
.Net framework provides five types of access specifiers
1) Public
2) Private
3) Internal
4) Protected
5) Protected Internal
public:
----------
Public is universal, we can access public members in the same class, instance classes, derived classes and other assemblies also. There is no restriction to use. So, it is universal access modifier.
Syntax:
----------
public datatype variablename;
public returntype methodname();
private:
----------
Private is strongly restricted for the same class/same method.
Syntax:
-----------
private datatype variablename;
private returntype methodname();
internal:
------------
internal works same as public, but the scope restricts for the same assembly. We can access through object or inherit, but other assembly we can't access either though object or inherit.
Syntax:
----------
internal datatype variablename;
protected:
-------------
"protected" member can be access through inheritance only. We can access protected in the same assembly or derived assembly through inherit only.
protected datatype variablename;
-----------------------
protected internal member can be accessed through object or inherit with in the same assembly, access through inherit only on other assembly.
It is the combination of "protected" and "internal".
protected internal datatype variablename;




SQL Server
C#.Net
ASP.Net
ADO.Net
jQuery

No comments:
Post a Comment