using Statement 用法 (C# Reference)
2006-10-17  作者:amao  同分类文章
description:
.NET Framework common language runtime (CLR), automatically releases the memory used to store objects that are no longer required.

 it is usually best to release limited resources such as file handles and network connections as quickly as possible.



using (StreamWriter sw = new StreamWriter("TestFile.txt"))
{
// Add some text to the file.
sw.Write("This is the ");
sw.WriteLine("header for the file.");
sw.WriteLine("-------------------");
// Arbitrary objects can also be written to the file.
sw.Write("The date is: ");
sw.WriteLine(DateTime.Now);
}
.NET CLR会自动释放不再需要的对象所占内存,但是有的时候需要尽快释放file handles & network connection


相关
WPF与Win32图形系统
几个.net开源项目
ASP.NET中文件上传下载方法集合
C#.net 中的编码 -Encoding
将DataGrid内容生成标准的Excel格式文件
ado.net 连接 mysql mysql.data.dll下载
Request.Form和Request.QueryString的区别
wpf(xaml)中的日历控件 Calendar
.NET Framework 3.0 常见问题 FAQ
最新.net framework 3.0 Windows SDK下载地址