what using the 'using' block in c# does to your code
Let us take a simple console application which has the below code written in it
static void Main(string args)
using (SqlConnection connection = new SqlConnection())
the IL that gets generated for the above program looks something like below...
L_000e: leave.s L_001a
L_0011: brfalse.s L_0019
.try L_0002 to L_0010 finally handler L_0010 to L_001a
On analyzing this IL what we realize is that this code is nothing but syntactic sugar for the try-finally block shown below
SqlConnection connection = new SqlConnection();
if(connection != null)
Overall a pretty neat feature to have...
Till my next post,