Fremus.co.za

Demistifying Life and Web Development

C# Access Modifiers

Today I was coding some C# and I decided to refresh my understanding of classes and how you declare methods and how they become accessible or inaccessible to other classes. C# has the following access modifiers, and depending on which one you use, it wll determine how other classes can use them:

  • Public: Members and methods declared as public are visible to any method and to any class outside that class.
  • Private: Members and Methods within a class marked as private are only accessible within that class
  • Protected: Members and Methods of a class marked as protected are only accessible to methods inside that class and any classes that derive from that class
  • Internal: The members in a class that are marked internal are accessible to methods of any class in that class’s assembly.
  • Share/Bookmark
posted by fr3dr1k in Application Development,C# and have No Comments

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment
Get Adobe Flash playerPlugin by wpburn.com wordpress themes