ResourceReader.Close 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
释放与此 ResourceReader 对象相关联的所有操作系统资源。
public:
virtual void Close();
public void Close ();
abstract member Close : unit -> unit
override this.Close : unit -> unit
Public Sub Close ()
实现
示例
以下示例在文件的资源中移动,并显示它找到的所有键/值对。 然后, Close 代码使用 方法关闭 ResourceReader 并释放它使用的所有资源。
using namespace System;
using namespace System::Resources;
using namespace System::Collections;
int main()
{
// Create a ResourceReader for the file items.resources.
ResourceReader^ rr = gcnew ResourceReader( "items.resources" );
// Create an IDictionaryEnumerator* to iterate through the resources.
IDictionaryEnumerator^ id = rr->GetEnumerator();
// Iterate through the resources and display the contents to the console.
while ( id->MoveNext() )
Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value );
rr->Close();
}
using System;
using System.Resources;
using System.Collections;
class EnumerateResources
{
public static void Main()
{
// Create a ResourceReader for the file items.resources.
ResourceReader rr = new ResourceReader("items.resources");
// Create an IDictionaryEnumerator to iterate through the resources.
IDictionaryEnumerator id = rr.GetEnumerator();
// Iterate through the resources and display the contents to the console.
while(id.MoveNext())
Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value);
rr.Close();
}
}
Imports System.Resources
Imports System.Collections
Class EnumerateResources
Public Shared Sub Main()
' Create a ResourceReader for the file items.resources.
Dim rr As New ResourceReader("items.resources")
' Create an IDictionaryEnumerator to iterate through the resources.
Dim id As IDictionaryEnumerator = rr.GetEnumerator()
' Iterate through the resources and display the contents to the console.
While id.MoveNext()
Console.WriteLine(ControlChars.NewLine + "[{0}] " + ControlChars.Tab + "{1}", id.Key, id.Value)
End While
rr.Close()
End Sub
End Class
注解
Close 可以安全地多次调用。