Monday, September 29, 2008

When to use using and when to use try catch to do the cleaning

  1. We have two ways to clean up utilized resources in C# either we can use try..catch..finally statements series or we can use the using statement in C#
  2. The thing is that resources should be released and cleanup must be performed either before exitting the using block or just entering up the finally block.
  3. Use using Statement in C# to release up the resources when the creating type implements the IDisposable interface.
  4. Use try..catch..finally when we need to perform cleanup but not necessarily employ the Dispose Method.


Post a Comment