001 Introduction To C Classes and Objects Example

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

/*************************************************************************

* Introduction to C# Classes and Objects Example


*
*************************************************************************/

using System;
namespace MyProject.Examples
{
class Box
{
public double l,b,h;

public double volume()


{
return (this.l * this.b * this.h);
}
}
class ExampleOne
{
public static void Main()
{
Box box1 = new Box();
box1.l = 45;
box1.b = 10;
box1.h = 20;

Console.WriteLine("Volume of box1 is {0}",


box1.volume());

Box box2 = new Box();


box2.l = 34;
box2.b = 50;
box2.h = 50;

Console.WriteLine("Volume of box2 is {0}",


box2.volume());

Console.ReadKey();
}
}
}

You might also like