38
1
using System;
2
3
public class Box
4
{
5
public int Height { get; set; }
6
public int Width { get; set; }
7
8
public Box(int h, int w)
9
{
10
Height = h;
11
Width = w;
12
}
13
14
public static bool operator <(Box box1, Box box2)
15
{
16
int area1 = box1.Height * box1.Width;
17
int area2 = box2.Height * box2.Width;
18
return area1 < area2;
19
}
20
public static bool operator >(Box box1, Box box2)
21
{
22
int area1 = box1.Height * box1.Width;
23
int area2 = box2.Height * box2.Width;
24
return area1 > area2;
25
}
26
}
27
28
public class Program
29
{
30
public static void Main()
31
{
32
Box box1 = new Box(15, 32);
33
Box box2 = new Box(44, 12);
34
35
Console.WriteLine("Is box1 < box2 ? {0}", box1 < box2);
36
Console.WriteLine("Is box1 > box2 ? {0}", box1 > box2);
37
}
38
}
Cached Result
Hello World