Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




QuestPond: Interview Questions and Answers on OOPS using C#.

What are different access modifiers?

There are 5 access modifiers. Access modifiers define scope for members.
  • Private: - Accessible only with in the class.
  • Protected: -Accessible with in the class and in derived classes.
  • Friend (internal in C#): -Accessible anywhere within the current project.
  • Protected friend (protected internal in C#): - Accessible with current project and derived classes.
  • Public: -Accessible everywhere.


Can we have different access modifiers on get/set methods of a property?

Yes, we can have different access modifiers. The below code will compile perfectly well.

public string CustName

{

    get

    {

        return _Custname;

    }

    protected set

    {

Custname = value;

    }

}





Helpful Website Url
http://www.questpond.com/
Share this article   |    Print    |    Article read by 2989 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles: No related article
Related Interview Questions: No related interview question