C#
  Home arrow C# arrow Page 3 - 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 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
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 / 72
    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 - The this keyword


    (Page 3 of 6 )

    The "this" keyword gets you an access to an instance of the class, and you can use it with instance methods, instance constructors and instance properties. You can't use it with any static members; this makes sense because a static member works on the class itself, not on an instance of it. Use the "this" keyword followed by the (.) operator to get access to the class members on an instance object. Take a look at the following class:

    using System;
    namespace Company
    {
    public class Employee
    {
    public string FirstName;
    public string LastName;

    //the default constructor
    public Employee()
    {
    this.FirstName = "Michael";
    this.LastName = "Youssef";
    }
    }
    }

    In the Employee class's default constructor I used the "this" keyword to initialize the public fields FirstName and LastName, so this keyword pretends that you already have an instance of the Employee class.

    Class members

    Inside a C# class you have defined: fields, properties, methods, constructors, destructor, indexers, constants, events, delegates and operators. We will discuss Fields, Constants and Static Types in this article; we will have separate articles for each of the other Class members.

    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

    - 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...
    - Color Transformation in C# GDI+ Programming
    - Exceptions in C#
    - Overriding versus Overloading
    - Value Types and Reference Types
    - Defining Member and Type Visibility
    - Managing Files in C#
    - Working with Windows Registry in C#
    - Lossless Image Resizing in C#
    - Lossless Image Converting in C#
    - Creating an RSS Feed with ASP.Net Written in...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway