Shivprasad Koirala
.NET interview questions: - What is public, private, protected, internal and internal protected?
By Shivprasad Koirala in ASP.NET on Apr 02 2011
  • Shivprasad Koirala
    Apr, 2011 2


    Answer:

    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.

    Regards,

    Please click here to see .NET and C# interview questions and answers

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS