如果该类型实现IDisposable,它将自动对其进行处理。
鉴于:
public class SomeDisposableType : IDisposable{ ...implmentation details...}这些是等效的:
SomeDisposableType t = new SomeDisposableType();try { OperateonType(t);}finally { if (t != null) { ((IDisposable)t).Dispose(); }}using (SomeDisposableType u = new SomeDisposableType()) { OperateonType(u);}第二个更易于阅读和维护。


![什么是C#Using块,为什么要使用它?[重复] 什么是C#Using块,为什么要使用它?[重复]](http://www.mshxw.com/aiimages/31/433085.png)
