static void Main(string[] args) { Time tm = new Time(-1,33,9); Console.WriteLine(tm.ToString()); tm.Hours = 3; tm.Minutes = 23; tm.Seconds = 50; Console.WriteLine("Hours is "+tm.Hours); // this will return different time because the equality operator == can not handle the class Time Time theTime = new Time(10, 0, 0); Time sameTime = new Time(10, 1, 0); if (theTime.Equals(sameTime)) Console.Write("Same time"); else Console.Write("Different time"); Console.ReadKey(); }
public Boolean Equals(Time someTime) { if (hours == someTime.hours && minutes == someTime.minutes && seconds == someTime.seconds) return true; else return false; }