Is there a better way to ignore an exception in C# than putting it up in a try catch block and doing nothing in catch? I find this syntax to be cumbersome. For a codeblock, can’t I simply “tag” it in such a way so as runtime knows which exceptions to neglect?
Share
I don’t think there is a trick to avoid exception but you can use the following code snippet:
Using the method looks like:
Another solution is to use AOP (Aspect Oriented Programming) – there’s a tool called PostSharp which enables you to create an attribute that would catch all exceptions in specific assembly/class/method, which is closer to what you’re looking for.