C# .net question: Write Implecite Cast method for given Time Class
Assume that the following method for class time is given :
public class Time
{
public int Hour{get; private set; }
public int Minute{get; private set; }
public int Second{get; private set; }
public Time (int hour, int minute, int second)
{
Hour = hour;
Minute = minute;
Second = second;
}
public override string ToString() =>
string.Format{“{Hour} hr {Minute} mn {Second} sc”};
following method is Main() method of the test program:
public static void Main()
{
Time t1= new Time(1, 59,59);
Time t2 = new Time();
t2 = 1;
Time T3 = t1 + t2 +3761;
Console.WriteLine{“First job lasts {0}”,t1};
Console.WriteLine{“next job lasts {0}”,t2};
Console.WriteLine{“total job lasts {0}”,t3};
Question . Write the complete method that would properly overload implicit type cast operator for the Time class.