.NET interview questions: - What is public, private, protected, internal and internal protected?

 Posted by ArticlesMaint on 3/31/2011 | Category: .NET Framework Interview questions | Views: 6795

In the following manner we can describe the C# access modifiers: -

public - The members (Functions & Variables) declared as public can be accessed from anywhere.

private - Private members cannot be accessed from outside the class. This is the default access specifier for a member, i.e if you do not specify an access specifier for a member (variable or function), it will be  considered as private. Therefore, string PhoneNumber; is equivalent to private string PhoneNumber;

protected - Protected members can be accessed only from the child classes.

internal - it can be accessed only within the same assembly.

internal Protected - internal protected can be accessed within the same assembly as well as in derived class.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Kishork80 on: 4/1/2011
Read in details with example code:


Login to post response