# Classes exercise Stopwatch: try/catch block

**URL:** <https://forum.codewithmosh.com/t/classes-exercise-stopwatch-try-catch-block/4082>\
**Category:** C#\
**Created:** [April 12, 2021, 6:06pm UTC](https://forum.codewithmosh.com/t/classes-exercise-stopwatch-try-catch-block/4082 "2021-04-12T18:06:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton2021](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/anton2021/32/1131_2.png) [@Anton2021](https://forum.codewithmosh.com/u/Anton2021)\
**Post date:** [April 12, 2021, 6:06pm UTC](https://forum.codewithmosh.com/t/classes-exercise-stopwatch-try-catch-block/4082/1 "2021-04-12T18:06:25Z")

</div>

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;
    }

}

```

}

---

<div class="post-metadata">

**Author:** ![Anton2021](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/anton2021/32/1131_2.png) [@Anton2021](https://forum.codewithmosh.com/u/Anton2021)\
**Post date:** [April 16, 2021, 8:50pm UTC](https://forum.codewithmosh.com/t/classes-exercise-stopwatch-try-catch-block/4082/3 "2021-04-16T20:50:04Z")

</div>

Much simpler than it seemed in the end:

throw new InvalidOperationException(“Stopwatch is already running”);
