Classes and Object Model in .NET

objects and classes, public classes, private classes, what is a class in c sharp examples 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

Popularity: unranked [?]

Related posts:

  1. “Hello World” Application Here we will guide you through step by step process...

Related posts brought to you by Yet Another Related Posts Plugin.

Tags: , , , , , , , , , , , ,

Leave a Reply

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

*
*