Use Not Disposible object in using statement : IDisposable with using « Class « C# / CSharp Tutorial






using System;
public class NotDisposible{}

public class MainClass
{
  public static void Main(string[] args)
  {

    // Uncomment to trigger compile time error.
    // using(NotDisposible x = new NotDisposible()){}

  } 
}








7.53.IDisposable with using
7.53.1.Dispose() is called automatically when the using block exits
7.53.2.Use Not Disposible object in using statement