在asp.net中使用关键字 [英] The use of Using Keyword in asp.net
本文介绍了在asp.net中使用关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请让我知道在asp.net中使用使用关键字的小例子
please let me know the use of "Using" keyword in asp.net with small example
推荐答案
using (SomeClass obj= new SomeClass())
{
obj.DoSomething();
}
to
{ // limits scope of obj
SomeClass obj= new SomeClass();
try
{
obj.DoSomething();
}
finally
{
// Check for a null resource.
if (obj!= null)
// Call the object's Dispose method.
((IDisposable)obj).Dispose();
}
}
Refer - 使用(C#参考) [ ^ ]。
Refer - using (C# Reference)[^].
引用:
使用 关键字有两个主要用途:
The using keyword has two major uses:
-
作为指令,用于为命名空间创建别名或导入在其他命名空间中定义的类型。请参阅使用指令。
作为声明,当它定义一个范围,在该范围的末尾将放置一个对象。请参阅使用声明。
As a statement, when it defines a scope at the end of which an object will be disposed. See using Statement.
理解C#中的'using'语句 [ ^ ]
C#中的使用关键字 [ ^ ]
查看链接。 .explanation详细示例..
Understanding the 'using' statement in C#[^]
The "using" Keyword in C#[^]
Check the links..explanation with detailed example..
这篇关于在asp.net中使用关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文