I’m working on the Ultimate C# series part II. I have most of the exercise done with working code. However, I cannot figure out how to implement a try/catch block that throws InvalidOperationException when the StartMethod() is run twice. Can anyone help with this ? This is my Stopwatch class:
using System;
namespace stopwatch
{
public class Stopwatch
{
public DateTime Start { get; private set; }
public DateTime Stop { get; private set; }
public DateTime StartMethod()
{
return Start = DateTime.Now;
}
public DateTime StopMethod()
{
return Stop = DateTime.Now;
}
}
}