C#
  Home arrow C# arrow Page 2 - C# Classes Explained
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

C# Classes Explained
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 74
    2005-04-05

    Table of Contents:
  • C# Classes Explained
  • Access Modifiers
  • The this keyword
  • Fields
  • Constants
  • Static members

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C# Classes Explained - Access Modifiers


    (Page 2 of 6 )

    You can control the visibility of class members for the other classes and other code using Access Modifier keywords: public, private, protected and internal. In C#, you must explicitly indicate the access modifiers for each member of you class, except from the private members, as we have observed. The next table discusses the available Access Modifiers:

    Access Modifier

    Description

    publicStates the the class member accessible for all the derived classes, classes in other assemblies and for any other code that want to you it.
    privateIt's the opposite of the public Access Modifier, states that the class member is not accessible for any code including derived classes so the only code that can access (or manipulate) this member is the declared class. Actually Object oriented Programming provide data protection using the private (and protected) Access Modifiers. For example, you can declare the salary field inside the Employee class as private and it will not be accessible and it will not be visible outside this class declaration so there's no client code that can modify its value unless you the programmer want that.
    protectedThis is an intermediate access level between the public and the private Modifiers. It states that the member is accessible for only derived classes which gives you the ability to declare fields that are not accessible outside the declared class and any class that derive it. For example, you can define a class like ManagerEmployee that derive and extend the Employee class.
    internalThis is an interesting Access Modifier that states that the class member is accessible only for the current assembly (we will have our discussion about assemblies later). This means that the member is public for the assembly but it's not visible outside the assembly.

    More C# Articles
    More By Michael Youssef


       · i m very new to c# pls tell me how to get a MSIL window i m using microsoft visual...
     

    C# ARTICLES

    - C# and XML
    - Pointers and Arrays in C#
    - C# 3.0 Extension Methods
    - Overloading Operators in C#
    - Iterators and Nullable Types
    - Patterns and Iterators in C#
    - C# Exceptions
    - Methods in C#
    - Delegates and Events in C#
    - Advanced C#
    - Working with Regular Expressions in C#
    - Sending Simple E-Mail in C#
    - Building C# Comparable Objects: IComparable ...
    - Color Transformation Applications in C# GDI+...
    - Performing Color Transformation Operations i...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT