在c#中使用有什么意义? [英] what is the significance of using in c#?
问题描述
您好,
昨天我遇到了伪代码:
string s;
使用(新的ClassA(你好))
{
for(int i = 0; i< some_count; i ++)
s =a;
s = null;
}
Class ClassA(字符串数据):IDisposable < br $>
{
public void Dispose()
{
//// /做一些处理
}
}
有人可以解释一下在这里使用关键字的意义吗?
谢谢和问候
Hello,
I came across a pseudo code yesterday :
string s;
using(new ClassA("hello"))
{
for(int i =0 ; i < some_count; i++)
s = "a";
s=null;
}
Class ClassA(string data) : IDisposable
{
public void Dispose()
{
/////do some disposal
}
}
can someone please explain me the significance of Using keyword here?
Thanks and Regards
推荐答案
CP有一篇很棒的文章基础帮助解决这些问题。看看了解C#中的'using'语句 [< a href =http://www.codeproject.com/Articles/6564/Understanding-the-using-statement-in-Ctarget =_ blanktitle =New Window> ^ ]文章。
CP has a great article base to help with questions like these. Take a look at Understanding the 'using' statement in C#[^] article.
查看此链接
http://msdn.microsoft.com/en-us/library/yh598w02.aspx [ ^ ]
请参考以下链接:
Link1 [ ^ ]
链路2 [ ^ ]
Link3 [ ^ ]
Please refer the following links :
Link1[^]
Link2[^]
Link3[^]
这篇关于在c#中使用有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!