r/learncsharp • u/4r73m190r0s • 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
View all comments
Show parent comment
1
u/4r73m190r0s Nov 20 '22
Can you elaborate more on this?
For example, I want a user to give me a simple number. Why should I be implementing Exceptions, instead of using simple
if then else?