Hi Bill, Thank you for your reply. I knew that, but the question is the practice of ignoring excpetions in "catch".
Using "is" and "as" is 10000% improvement over a ignoring the exception in that example by any means, that was also suggested by Eddie. But why or when would one ignore the specific exception when it could have been preventet and ignore it instead? Regards Arjang On 1 June 2010 10:58, Bill McCarthy <[email protected]> wrote: > Hi Arjang, > > In C# use the "as" operator and check for null; in VB use TryCast and check > for Nothing. > > > |-----Original Message----- > |From: [email protected] [mailto:ozdotnet- > |[email protected]] On Behalf Of Arjang Assadi > |Sent: Tuesday, 1 June 2010 10:39 AM > |To: ozDotNet > |Subject: Ignoring excpetions in catch > | > |I thought only the beginner programmers or programmers without any > |pride in their work or self discipline would write code like this: > | > |try > |{ > | //some code goes here > |} > |catch > |{ > | //No code here just business as usual, do nothing about the exceptions! > |} > | > |but maybe I am wrong, this http://support.microsoft.com/kb/319465 was > |unexpected! > |in the code in the above link are there any reasons for > |1)Checking the type, or more generally first checking that at least > |the minimum requirements of an operations will be satisfied before > |using a sledge hammer? > | > |2)Using some other (better) code e.g. reflection etc. would be > |definitely more preferable to ignoring excpetion? > | > |3)Any other suggestions? > | > |Regards > | > |Arjang > >
