try-catch and using statements in exception handling #31951
Labels
doc-enhancement
Improve the current content [org][type][category]
dotnet-csharp/svc
fundamentals/subsvc
Pri1
High priority, do before Pri2 and Pri3
📌 seQUESTered
Identifies that an issue has been imported into Quest.
It says, "Use a try-catch statement for most exception handling" and proceeds to show an example where the exception could be avoided by doing bounds checks. I don't think this should be a recommended coding convention since exception-based programming is more expensive than mitigating exceptions that can be prevented.
If anything, this should demonstrate catching an exception that you can't prevent (i.e. SocketException in some cases), and not catching the System.Exception type but the most relevant derived exception as a best practice.
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
Associated WorkItem - 123090
The text was updated successfully, but these errors were encountered: