Suppose I have the following:
using(var ctx = DataContextFactory.Create(0))
{ ... Some code ... }
Why not just do the following and lose a
The using statement gives you nice syntax plus exception protection. You cannot leave the using statement without calling Dispose (it translates into a finally block with a call to dispose). In your second scenario, if you had an exception between the Create and the Dispose, you would not call dispose directly. Which is not a problem unless you are using unmanaged resources, but if you are, you will leak.