ResXResourceReader.Close Metod

Definition

Släpper alla resurser som används av ResXResourceReader.

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

Implementeringar

Exempel

I följande exempel visas resurserna i en fil i konsolen och metoden används Close sedan för att stänga av läsaren och för att göra dess resurser tillgängliga för andra processer.

using System;
using System.Resources;
using System.Collections;

class ReadResXResources
{
   public static void Main()
   {

      // Create a ResXResourceReader for the file items.resx.
      ResXResourceReader rsxr = new ResXResourceReader("items.resx");

      // Iterate through the resources and display the contents to the console.
      foreach (DictionaryEntry d in rsxr)
      {
    Console.WriteLine(d.Key.ToString() + ":\t" + d.Value.ToString());
      }

     //Close the reader.
     rsxr.Close();
   }
}
Imports System.Resources
Imports System.Collections

Class ReadResXResources
   
   Public Shared Sub Main()
      
      ' Create a ResXResourceReader for the file items.resx.
      Dim rsxr As ResXResourceReader
      rsxr = New ResXResourceReader("items.resx")

      ' Iterate through the resources and display the contents to the console.
      Dim d As DictionaryEntry
      For Each d In  rsxr
         Console.WriteLine(d.Key.ToString() + ":" + ControlChars.Tab + d.Value.ToString())
      Next d
      
      'Close the reader.
      rsxr.Close()

   End Sub

End Class

Kommentarer

Anrop Close gör att de resurser som används av ResXResourceReader kan omallokeras för andra ändamål. Mer information om Closefinns i Rensa ohanterade resurser.

Gäller för