by Nick
9. November 2006 12:55
Rory shows us a couple of examples of how to use the C# using statement. Thankfully VB 2005 also includes this statement so that VB.NET coders can write:
Using ts As New Data.SqlClient.SqlConnection, _
ts2 As New Data.SqlClient.SqlConnection
'Do stuff...
End Using
What I would like to see is a compiler that is intilligent enough so that if I declare an IDisposable object on the stack (ie as a method variable) it will automatically call dispose when the method exits. This would mostly negate the need for the using statement. Oh, wait doesn't the Managed C++/CLI compiler do this....
5599df9c-5cf0-46dc-bac0-d7d5760790de|0|.0
Tags: Languages