tagged [using-statement]
Are resources disposed even if an exception is thrown in a using block?
Are resources disposed even if an exception is thrown in a using block? > [Does Dispose method still get called when Exception is thrown inside of Using statment?](https://stackoverflow.com/questions...
- Modified
- 23 May at 12:25
Implementing C++ equivalent of C# using statement
Implementing C++ equivalent of C# using statement I am looking for an elegant solution for implementing the equivalent of the C# using statement in C++. Ideally the resultant syntax should be simple t...
- Modified
- 26 Mar at 21:0
Best practice for nested using statements?
Best practice for nested using statements? I have a code block as follows and I'm using 3 nested `using` blocks. I found that using `try finally` blocks I can avoid this but if there are more than two...
- Modified
- 3 May at 08:4
C#: "Using" Statements with HttpWebRequests/HttpWebResponses
C#: "Using" Statements with HttpWebRequests/HttpWebResponses Jon Skeet [made a comment (via Twitter)](http://twitter.com/jonskeet/statuses/6625278613) on my [SOApiDotNet](http://soapidotnet.googlecode...
- Modified
- 20 Jun at 09:12
Is it possible to extend the 'using' block in C#?
Is it possible to extend the 'using' block in C#? Is there a way to extend the `using` block in C# in such a way that takes a delegate as a second parameter alongside an IDisposable object and execute...
- Modified
- 28 Feb at 18:29
Using Statements vs Namespace path? C#
Using Statements vs Namespace path? C# I recently stopped using [using-statement](/questions/tagged/using-statement)s and instead use the full namespace path of any [.net](/questions/tagged/.net) obje...
- Modified
- 19 Mar at 14:36
What scope does a using statement have without curly braces
What scope does a using statement have without curly braces I inherited the following code: ``` using (var dataAccessConnection = da.GetConnection()) //no opening curly brace here using (var command...
- Modified
- 18 Jul at 07:40
Why use a using statement with a SqlTransaction?
Why use a using statement with a SqlTransaction? I've been running into some problems concerning a SqlTransaction I'm using in my code. During my Googling I see many people using a using statement wit...
- Modified
- 24 Dec at 07:41
Will a using statement rollback a database transaction if an error occurs?
Will a using statement rollback a database transaction if an error occurs? I've got an IDbTransaction in a using statement but I'm unsure if it will be rolled back if an exception is thrown in a using...
- Modified
- 14 Mar at 00:52
Closing SqlConnection and SqlCommand c#
Closing SqlConnection and SqlCommand c# In my DAL I write queries like this: Now it just occurred to me that I am not explicitly closing the SQLCommand object. Now I know the 'using' block will take c...
- Modified
- 30 Jul at 11:34
Does a C# using statement perform try/finally?
Does a C# using statement perform try/finally? Suppose that I have the following code: ``` private void UpdateDB(QuoteDataSet dataSet, Strint tableName) { using(SQLiteConnection conn = new SQLiteCo...
- Modified
- 25 Apr at 21:25
When are C# "using" statements most useful?
When are C# "using" statements most useful? So a using statement automatically calls the dispose method on the object that is being "used", when the using block is exited, right? But when is this nece...
- Modified
- 26 Sep at 02:51
Does Dispose still get called when exception is thrown inside of a using statement?
Does Dispose still get called when exception is thrown inside of a using statement? In the example below, is the connection going to close and disposed when an exception is thrown if it is within a `u...
- Modified
- 23 May at 12:2
Can I combine a using() {} block with a method's out parameter?
Can I combine a using() {} block with a method's out parameter? Given a method And a piece of calling code: I'm using the same pattern as `b
- Modified
- 19 Nov at 18:33
C# 'using' statement question
C# 'using' statement question If you employ a using clause to dispose of a connection, are other items within the clause that implement IDisposable also automatically disposed? If not, how do you hand...
- Modified
- 25 Apr at 22:38
Calling Dispose() vs when an object goes out scope/method finishes
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 follows: In the `fin...
- Modified
- 11 Jan at 15:39
Do using statements and await keywords play nicely in c#
Do using statements and await keywords play nicely in c# I have a situation where I am making an `async` call to a method that returns and `IDisposable` instance. For example: Now before `async` was o...
- Modified
- 19 Dec at 16:25
C#, weird optimization
C#, weird optimization I'm trying to read my compiled C# code. this is my code: But! We all know that a using gets translated to this: ``` { OleDbCommand insertCommand = new OleDbCommand("...", conn...
- Modified
- 7 May at 13:13
How to determine whether a .NET exception is being handled?
How to determine whether a .NET exception is being handled? We're investigating a coding pattern in C# in which we'd like to use a "using" clause with a special class, whose `Dispose()` method does di...
- Modified
- 25 Mar at 19:10
using on SQLDataReader
using on SQLDataReader I know I asked a related question earlier. I just had another thought. ``` using (SqlConnection conn = new SqlConnection('blah blah')) { using(SqlCommand cmd = new SqlCommand(...
- Modified
- 20 Aug at 15:13
C# using statement catch error
C# using statement catch error I am just looking at the using statement, I have always known what it does but until now not tried using it, I have come up with the below code: ``` using (SqlCommand cm...
- Modified
- 12 Aug at 19:18
Why is using(null) a valid case in C#?
Why is using(null) a valid case in C#? Could someone please explain to me why the code shown below is valid in C# and executes the call to `Console.WriteLine`? It compiles into (finally block is shown...
- Modified
- 4 Mar at 08:49
Why can't I reference System.Runtime.Serialization.Json in C#
Why can't I reference System.Runtime.Serialization.Json in C# I want to use an API to get info from the interwebz. The API returns data in Json format. 1. I'm running Microsoft Visual Studio C# 2010 E...
- Modified
- 6 Jun at 10:27
Use of Process with using block
Use of Process with using block > [What happens if I don't close a System.Diagnostics.Process in my C# console app?](https://stackoverflow.com/questions/185314/what-happens-if-i-dont-close-a-system-d...
- Modified
- 23 May at 11:51
The type or namespace name could not be found
The type or namespace name could not be found I have a `C#` solution with several projects in `Visual Studio 2010`. One is a test project (I'll call it ""), the other is a `Windows Forms Application` ...
- Modified
- 2 Nov at 11:14