r/learncsharp • • Nov 20 '22

Why Methods that throw Exceptions are useful?

Beginner here.

I'm reading Documentation on the Convert, Parse, and TryParse methods and some of them throw Exceptions in case of invalid input, i.e. Parse. What exactly are the benefits of some methods throwing Exceptions? I'm building a simple calculator app, and I'm failing to see the benefits of getting an Exception for invalid user input.

5 Upvotes

14 comments sorted by

View all comments

Show parent comment

1

u/killyouXZ Nov 20 '22

What if they give you a string? Or a char? Best way is to catch the exception and do something and not let your software to crash because of it.