Home arrow C# arrow Page 4 - Introduction to Objects and Classes in C#
C#

Introduction to Objects and Classes in C#


In this article Michael introduces us to C#, as well as attempts to demystify the theory behind "Object and Classes" in OO Programming.

Author Info:
By: Michael Youssef
Rating: 5 stars5 stars5 stars5 stars5 stars / 496
September 16, 2003
TABLE OF CONTENTS:
  1. · Introduction to Objects and Classes in C#
  2. · Introduction
  3. · World's Classes and Objects
  4. · Programmerís Classes and Objects
  5. · Properties and Variables
  6. · Properties
  7. · Reworked
  8. · Creating Objects and Classes
  9. · Conclusion

print this article
SEARCH DEVARTICLES

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.


blog comments powered by Disqus
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#

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials