Code Standard 2.0 new objects outside of Try Block
- From: "gabe" <gabedog@xxxxxxxxx>
- Date: 9 Aug 2006 07:42:17 -0700
I have question about code standards in VS 2005
I have been declaring objects before a try block in case I would ever
want to refer to them in 'Catch' block. When I converted my apps to 2.0
I get warnings that objects have been declared, but not initialized.
I've hesitated to actually 'New' an object outside of a try in the
event of an exception occurring. For example, if I new up a Connection
object with a connection string with an incorrect syntax it will throw
an InvalidArgument exception.
What's a best practice for this?
(I don't use Try Blocks in every method, but when I do, I want to make
sure that things are being trapped)
Thanks,
Gabe
.
- Follow-Ups:
- Re: Code Standard 2.0 new objects outside of Try Block
- From: Cor Ligthert [MVP]
- Re: Code Standard 2.0 new objects outside of Try Block
- From: Mike Lowery
- Re: Code Standard 2.0 new objects outside of Try Block
- From: Siva M
- Re: Code Standard 2.0 new objects outside of Try Block
- Prev by Date: Re: Creating Snippets
- Next by Date: Re: Creating Snippets
- Previous by thread: Problem with form designer section when adding a component
- Next by thread: Re: Code Standard 2.0 new objects outside of Try Block
- Index(es):
Relevant Pages
|