C#
  Home arrow C# arrow Page 4 - Introduction to Objects and Classes in C#
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
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#

Introduction to Objects and Classes in C#
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 307
    2003-09-16

    Table of Contents:
  • Introduction to Objects and Classes in C#
  • Introduction
  • World's Classes and Objects
  • Programmer’s Classes and Objects
  • Properties and Variables
  • Properties
  • Reworked
  • Creating Objects and Classes
  • Conclusion

  • 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


    Introduction to Objects and Classes in C# - Programmer’s Classes and Objects


    (Page 4 of 9 )

    A C# Class is considered to be the primary building block of the language. What I mean by the primary building block is that every time you work with C# you will create classes to form a program. We use classes as a template to put the properties and functionalities or behaviors in one building block for a group of objects and after that we use the template to create the objects we need.

    For example, we need to have persons objects in our program so the first thing to do here is to create a class called Person that contains all the functionalities or behaviors and properties of any person and after that we will use that class (or template) to create as many objects as we need. Creating an object of a specific class type is called "an instance of the class". Don't worry if you didn't grasp it 100% and don't worry if you don't know what the class and object's properties and functionalities or behaviors are because we are still in the beginning.  Until now I haven’t provided any code examples. So let's take a brief of what is a class and what is an object:

    The class: A building block that contains the properties and functionalities that describe some group of objects. We can create a class Person that contains:

    1. The properties of any normal person on the earth like: hair color, age, height, weight, eye color.
    2. The functionalities or behaviors of any normal person on the earth like: drink water, eat, go to the work.

    Later we will see how we can implement the functionalities or behaviors and properties.

    There are 2 kinds of classes: The built-it classes that come with the .NET Framework, called Framework Class Library, and the programmer defined-classes which we create ourselves.

    The class contains data (in the form of variables and properties) and behaviors (in the form of methods to process these data). We will understand this concept later on in the article.

    When we declare a variable in a class we call it member variables or instance variables. The name instance come from the fact that when we create an object we instantiate a class to create that object.  So instance of a class means an object of that class and instance variable means variable that exists in that class.

    The object: It's an object of some classification (or class, or type) and when you create the object you can specify the properties of that object. What I mean here is: I, as an object, can have different properties (hair color, age, height, weight) than you as another object. For example, I have brown eyes and you have green eyes.  When I create 2 objects I will specify a brown color for my object's eye color property and I will specify a green color for your object's eye color property.

    So to complete my introduction to classes we must discuss properties and variables.

    More C# Articles
    More By Michael Youssef


       · sirthis artical was very good...even a lay man can understand this. iam from a...
       · Great for beginners !! It helped me a lot. Thanks!
       · very good ......but blank output...
       · very god article for beginners.. i benefitted alot, highly recommended to...
       · This article is very good for beginners like me.In page 8 of this article you...
       · Thanks for your post, could you please specify what is it that you need to...
       · Thank you for your reply.At the end of the page you talked about constructors and...
       · this article is simply superb,i learned a lot of basics from this article,and ...
     

    C# ARTICLES

    - Introduction to Objects and Classes in C#, P...
    - Visual C#.NET, Part 1: Introduction to Progr...
    - C# - An Introduction
    - Hotmail Exposed: Access Hotmail using C#
    - Razor Sharp C#
    - Introduction to Objects and Classes in C#
    - Making Your Code CLS Compliant
    - Programming with MySQL and .NET Technologies
    - Socket Programming in C# - Part II
    - Socket Programming in C# - Part I
    - Creational Patterns in C#
    - Type Conversions
    - Creating Custom Delegates and Events in C#
    - Inheritance and Polymorphism
    - Understanding Properties in C#






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