ResourceSet.Close 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
關閉並釋出這個 ResourceSet 所使用的任何資源。
public:
virtual void Close();
public virtual void Close ();
abstract member Close : unit -> unit
override this.Close : unit -> unit
Public Overridable Sub Close ()
範例
下列程式代碼範例會 Close 使用 方法來釋放呼叫 ResourceSet 實例所使用的所有資源。
using namespace System;
using namespace System::Resources;
using namespace System::Collections;
int main()
{
// Create a ResourceSet for the file items.resources.
ResourceSet^ rs = gcnew ResourceSet( "items.resources" );
// Create an IDictionaryEnumerator* to read the data in the ResourceSet.
IDictionaryEnumerator^ id = rs->GetEnumerator();
// Iterate through the ResourceSet and display the contents to the console.
while ( id->MoveNext() )
Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value );
rs->Close();
}
using System;
using System.Resources;
using System.Collections;
class EnumerateResources
{
public static void Main()
{
// Create a ResourceSet for the file items.resources.
ResourceSet rs = new ResourceSet("items.resources");
// Create an IDictionaryEnumerator to read the data in the ResourceSet.
IDictionaryEnumerator id = rs.GetEnumerator();
// Iterate through the ResourceSet and display the contents to the console.
while(id.MoveNext())
Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value);
rs.Close();
}
}
Imports System.Resources
Imports System.Collections
Class EnumerateResources
Public Shared Sub Main()
' Create a ResourceSet for the file items.resources.
Dim rs As New ResourceSet("items.resources")
' Create an IDictionaryEnumerator to read the data in the ResourceSet.
Dim id As IDictionaryEnumerator = rs.GetEnumerator()
' Iterate through the ResourceSet and display the contents to the console.
While id.MoveNext()
Console.WriteLine(ControlChars.NewLine + "[{0}] " + ControlChars.Tab + "{1}", id.Key, id.Value)
End While
rs.Close()
End Sub
End Class
備註
呼叫這個方法 ResourceSet 之後,對方法的所有呼叫都可能會失敗。
Close 可以安全地呼叫多次。