Question: C# .net question: Write Implecite Cast method for given Time Class Assume that the following method for class time is given : public class Time

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!