C# using的三种作用

1、指定引用类型的命名空间,例如:

using System.Windows.Forms;

2、简化命名空间的层次表达式,例如:

using WinForm = System.Windows.Form;

3、作为语句,定义一个范围。

程序执行到"}"时,就会自动释放font1对象

例如:

Font font1 = new Font("Arial", 10.0f);
using (font1) {
    ...
}

猜你喜欢

转载自blog.csdn.net/weixin_40522523/article/details/88286653