What will be the output of the following C# code?
class box
{
public int volume;
int width;
int height;
int length;
public box ( int w, int h, int l)
{
width = w;
height = h;
length = l;
}
public ~box()
{
volume = width * length * height;
}
}
class Program
{
static void Main(string[] args)
{
box b = new box(4, 5, 9);
Console.WriteLine(b.volume);
Console.ReadLine();
}
}
class box
{
public int volume;
int width;
int height;
int length;
public box ( int w, int h, int l)
{
width = w;
height = h;
length = l;
}
public ~box()
{
volume = width * length * height;
}
}
class Program
{
static void Main(string[] args)
{
box b = new box(4, 5, 9);
Console.WriteLine(b.volume);
Console.ReadLine();
}
}A. 0
B. 180
C. Compile time error
D. None of the mentioned
Answer: Option C
Related Questions on Classes and Objects in C Sharp
A. A blueprint for creating objects
B. A method in C#
C. A variable in C#
D. A data type in C#
A. A method in C#
B. A variable in C#
C. An instance of a class
D. A data type in C#
A. public
B. private
C. protected
D. internal

Join The Discussion