ResourceSet.Close ResourceSet.Close ResourceSet.Close ResourceSet.Close Method

Definizione

Chiude e rilascia qualsiasi risorsa usata da questo oggetto ResourceSet.Closes and releases any resources used by this ResourceSet.

public:
 virtual void Close();
public virtual void Close ();
abstract member Close : unit -> unit
override this.Close : unit -> unit
Public Overridable Sub Close ()

Esempi

Il codice seguente viene illustrato come utilizzare il Close metodo per rilasciare tutte le risorse usate dal chiamante ResourceSet istanza.The following code example uses the Close method to release all resources used by the calling ResourceSet instance.

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
Imports System.Resources
Imports System.Collections
Imports Microsoft.VisualBasic

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

Commenti

Tutte le chiamate ai metodi nel ResourceSet dopo una chiamata a questo metodo potrebbe non riuscire.All calls to methods on the ResourceSet after a call to this method might fail.

Close può essere chiamato in modo sicuro più volte.Close can be safely called multiple times.

Nota

L'implementazione corrente delle Close chiamate Dispose (true).The current implementation of Close calls Dispose (true).

Si applica a