code4it-dev / blog-comments

https://www.code4it.dev/
1 stars 0 forks source link

csharptips/exception-handling-when-clause #31

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

C# Tip: Exception handling with WHEN clause - Code4IT

Instead of using if-else or switch blocks to handle exceptions, you can do it gracefully using the 'when' keyword.

https://www.code4it.dev/csharptips/exception-handling-when-clause

Bharathidh commented 1 year ago

I have had a chance to look at performance of both WHEN vs IF clause in exception handling they were pretty close but when I looked at IL commands in ILSpy , WHEN ran a lot more commands than IF. So, I decided to use IF. would you still choose WHEN after reading this?