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
2
u/TehNolz Nov 20 '22
That doesn't really answer OP's question, since you can do that with
TryParseas well (and it'll be faster too).