I prefer the second one. May as well trap errors relating to the creation of the object as well.
More Related Contents:
- Try-Catch-Finally c# in Console [closed]
- What are the uses of “using” in C#?
- What is the C# Using block and why should I use it? [duplicate]
- The type or namespace name could not be found [duplicate]
- C# catch a stack overflow exception
- Why catch and rethrow an exception in C#?
- How using try catch for exception handling is best practice
- Do try/catch blocks hurt performance when exceptions are not thrown?
- Does the C# “finally” block ALWAYS execute? [duplicate]
- ‘using’ statement vs ‘try finally’
- Main method code entirely inside try/catch: Is it bad practice?
- What is the real overhead of try/catch in C#?
- returning in the middle of a using block
- Try-catch speeding up my code?
- Why is try {…} finally {…} good; try {…} catch{} bad?
- When to use try/catch blocks?
- What happens if i return before the end of using statement? Will the dispose be called?
- Wrong line number on stack trace
- SqlCommand with using statement
- Will a using statement rollback a database transaction if an error occurs?
- Why use a using statement with a SqlTransaction?
- The C# using statement, SQL, and SqlConnection
- Is it “bad” to use try-catch for flow control in .NET?
- What and when is “using” block used for in C#? How to use “using” block in C#?
- When is “using” block used for in C#? How to use “using” block in C#?
- When should I use the using Statement? [duplicate]
- Is it bad practice to return from within a try catch finally block?
- How to handle WCF exceptions (consolidated list with code)
- C# Compiler should give warning but doesn’t?
- using statement with multiple variables [duplicate]