1. public - The member can be accessed from anywhere
2. internal - The member can only be accessed from type it
originates from or other types in the same assembly
3. protected - The member can only be accessed from the type
it originates from or from detrieved types of the
4. protected internal - implies protected OR internal ( not
protected AND internal )
5. private - The member is only accessible by other members
within the type it originates from.
1. Public: Any member declared public can be accessed from
outside the class.
2. Private: it allows a class to hide its member variables
and member functions from other class objects and function.
Therefore, the private member of a class is not visible
outside a class. if a member is declared private, only the
functions of that class access the member.
3. Protected: This also allows a class to hide its member
var. and member func. from other class objects and
function, except the child class. it becomes important
while implementing inheritance.
4. Internal: Internal member can be expose to other
function and objects. it can be accessed from any class or
method defined within the application in which the member
5. Protected Internal: it's similar to Protected access
specifier, it also allows a class to hide its member
variables and member function to be accessed from other
class objects and function, excepts child class, within the
application. used while implementing inheritance.
1. public member can be accessed by any other code in
2. Main() is declared as public because it will be called
by code outside of its class (the operating system).
3. private member can be accessed only by other members
of its class.
4. A protected member is public within a class hierarchy,
but private outside that hierarchy.
5. A protected member is created by using the protected
6. The internal modifier declares that a member is known
throughout all files in an assembly, but unknown outside
7. The protected internal access level can be given only
to class members.
8. A member declared with protected internal access is
accessible within its own assembly or to derived types.
C# provide five access specifiers , they are as follows :
public, private , protected , internal and protected
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.
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.
The scope of accessibility is limited within the class or
struct and the class derived (Inherited )from this class.
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.
What is the Use Of Interfaces?
For example I have a interface as shown below?
public void MyMethod();
class MyClass : IMyInterface
public void Mymethod()
static void Main(string args)
MyClass obj = new MyClass();
Here What is My Question is?
If i remove Interface and run this code, it will executed then what is the Use
of the interface? Can any one give me the solution for this Problem?
Thanks in Advance!