Using statement - Why it's so good

John Papa explains here the difference it makes with and without the new Using statement.

 

2 Comments

  • Finally VB.NET catches up on C# :-) Seriously though the using statement really does rule for ensuring you don't leak resources...

  • If your argument for using the 'using' statement is that 'finally' blocks can be forgotten when writing code what makes you think that the same developers will remember to use 'using'? If they do not understand the idea of cleaning up it doesn't matter how many ways they have to do it. And since 'using' can only handle one type at a time it will imho make the code much more difficult to understand if you're using more than one type that needs to be cleaned up. Escpecially if there are dependencies between each variable (i.e. first close an open command, then the connection).

Comments have been disabled for this content.