static void Main1(string[] args) { Time t1 = new Time(10, 20, 30); Time t2 = new Time(10, 20, 30); // t2 = t1; if (t1.Equals(t2)) { Console.WriteLine("Equal"); } else { Console.WriteLine("Not Equal"); } }
static void Main2(string[] args) { Time t1 = new Time(10, 1, 20); Time t2 = new Time(1, 20, 30); Time t3; t3 = t1 + t2; // Time.operator+(t1,t2); if (t1 > t2) //Time.operator>(t1,t2) { Console.WriteLine("t1 is greater"); } else { Console.WriteLine("t2 is greater"); } }
static void Main() { Time t1 = new Time(1, 1, 2); Console.WriteLine(t1[10]); }
public static Time operator +(Time t1, Time t2) { Time t = new Time(); t.hr = t1.hr+t2.hr; t.min = t1.min + t2.min; t.sec = t1.sec + t2.sec; return t; }