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 可以安全地呼叫多次。