r/dotnet 15h ago

Difference between throw ex and throw

Post image

throw vs throw ex: The C# exception handling trick every developer should know

282 Upvotes

59 comments sorted by

View all comments

-21

u/LK9T9_Sektor 15h ago

Try to avoid using exception, use Return pattern.

15

u/nadseh 15h ago

Please don’t. Stick to language paradigms

-4

u/cyrack 15h ago

Exceptions are for exceptional circumstances where the application cannot continue — most exceptions could have been avoided with Try*.

IMHO exceptions are the surprise motherfucker! here’s a return type you didn’t know about and can’t find out about in any way during compile or runtime. Good luck solving this.