using
is basically the equivalent of:
try
{
// code
}
finally
{
obj.Dispose();
}
So it also has the benefit of calling Dispose()
even if an unhandled exception is thrown in the code within the block.
More Related Contents:
- What is a NullReferenceException, and how do I fix it?
- What is the best workaround for the WCF client `using` block issue?
- Custom Compiler Warnings
- Nested using statements in C#
- Difference in months between two dates
- Way to have String.Replace only hit “whole words”
- When should I use “using” blocks in C#? [duplicate]
- When is a custom attribute’s constructor run?
- Capture screenshot Including Semitransparent windows in .NET
- How do I determine a mapped drive’s actual path?
- Get File Icon used by Shell
- How is performance affected by an unused using directive?
- How to find overlapping controls that I added to form?
- Inconsistency in divide-by-zero behavior between different value types
- Is String a primitive type?
- What is a predicate in c#? [duplicate]
- Difference between Lookup() and Dictionary(Of list())
- yield return statement inside a using() { } block Disposes before executing
- BinaryWriter Endian issue
- Questions about Entity Framework Context Lifetime
- .NET Configuration (app.config/web.config/settings.settings)
- How to Start a Process Unelevated
- Save Settings in VB.Net or C#
- .NET graph library around? [closed]
- center MessageBox in parent form [duplicate]
- using statement FileStream and / or StreamReader – Visual Studio 2012 Warnings
- What steps do I need to take to use WCF Callbacks?
- How to insert a Symbol (Pound, Euro, Copyright) into a Textbox
- Dynamically changing Textbox’s AutoComplete List causes AccessViolationException, any advice?
- As of today, what is the right way to work with COM objects? [duplicate]