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

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

* Constructor and Destructors in C# Example


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

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

public double volume()


{
return (this.l * this.b * this.h);
}
public Box(double la,double br,double hi)
{
this.l = la;
this.b = br;
this.h = hi;
}
~Box(){
Console.WriteLine("The Distructor is called");
}
}
class ExampleOne
{
public static void Main()
{
Box box1 = new Box(46,60,20);

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


box1.volume());

Console.ReadKey();
}
}
}

You might also like