Top "Using-statement" questions

A `using` statement is a C# and VB.

Why is a variable declared in a using statement treated as readonly?

Why using variable treated as readonly? It is c# language specification or managed languages specification? It is because c# is …

c# .net using-statement object-lifetime
Calling Dispose() vs when an object goes out scope/method finishes

I have a method, which has a try/catch/finaly block inside. Within the try block, I declare SqlDataReader as …

c# idisposable using using-statement
Can the C# using statement be written without the curly braces?

I was browsing a coworkers c# code today and found the following: using (MemoryStream data1 = new MemoryStream()) using (MemoryStream data2 = …

c# using-statement
HttpClient in using statement causes Task cancelled

I created a FileResult : IHttpActionResult webapi return type for my api calls. The FileResult downloads a file from another url …

c# asp.net-web-api task-parallel-library httpclient using-statement
C# conditional using block statement

I have the follow code but it is awkward. How could I better structure it? Do I have to make …

c# idisposable using-statement
Using for IDbConnection/IDbTransaction safe to use?

While my assumption may seem to sound subjective, after some research, I found that it's not uncommon to find developers …

c# vb.net transactions database-connection using-statement
When Using statement should be used?

A lot of people on SO pointed out that I should use using statement more often. So I am practicing. …

c# using-statement
Use of Process with using block

Possible Duplicate: What happens if I don't close a System.Diagnostics.Process in my C# console app? As System.Diagnostics.…

c# process coding-style idisposable using-statement
Using statement around dialog form to ensure garbage collection

We have a Windows Forms application that contains thousands of forms. Many of these are temporarily displayed as dialogs via …

c# winforms garbage-collection using-statement resource-leak
Dealing with .NET IDisposable objects

I work in C#, and I've been pretty lax about using using blocks to declare objects that implement IDisposable, which …

c# .net visual-studio idisposable using-statement