Tutorials » DotNet tutorials »

Classes and Object model in .NET


Classes and Object model in .NET




We will start with an introduction to what is object oriented programming, how to write simple classes, creating objects etc.

What is a 'class' ?

In modern object oriented programming, large computer programs are divided into several 'classes'. Typically, a large project will have several hundred classes. A class represents an entity in a program. For example, if you are doing a small program called calculator, you will typically have a single (or more) class called 'Calculator' (you can give any name for your class). The class will have several 'methods', that will do the functionality of the class.

So, your calculator may have methods like the following:
Add()
Subtract()
Multiply()
Divide()

Here is a sample calculator class, written in C# :


using System;

public class Calculator
{
public int Add(int value1, int value2)
{
return value1 + value2;
}

public int Subtract(int value1, int value2)
{
return value1 - value2;
}

public int Multiply(int value1, int value2)
{
return value1 * value2;
}

public int Divide(int value1, int value2)
{
return value1 / value2;
}
}



Classes and objects

[To be added.]

Object model in .NET

[To be added.]






Next Chapter: Property in C# class
Previous Chapter: DataTypes in C#
More Chapters: .NET Tutorials
More Tutorials: Tutorial Index



Top Contributors
Today
    Last 7 Daysmore...

    Awards & Gifts

    Online Members

    Murugesan.P
    More...
     
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India