C#的using語句
阿新 • • 發佈:2018-12-30
# MyObject.cs
using System;
namespace MyProjects
{
public class MyObject : IDisposable
{
public MyObject()
{
}
public void Dispose ( )
{
// Dispose
Console.WriteLine (
"
Disposed
"
) ;
//
}
}
}
# Class1.cs
using System;
namespace MyProjects
{
public class Class1
{
public Class1()
{
}
public static void
Main (
string
[] args )
{
using ( MyObject myObject = new MyObject ( ) )
{
Console.WriteLine ( " quit " ) ;
}
}
}
}
using System;
namespace MyProjects
{
public class MyObject : IDisposable
{
public MyObject()
{
}
public void Dispose ( )
{
// Dispose
Console.WriteLine (
//
}
}
}
# Class1.cs
using System;
namespace MyProjects
{
public class Class1
{
public Class1()
{
}
public static void
{
using ( MyObject myObject = new MyObject ( ) )
{
Console.WriteLine ( " quit " ) ;
}
}
}
}