ResourceSet.Close 方法

定义

关闭并释放由此 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 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 可以安全调用多次。

注释

调用DisposeClose当前实现(true)。

适用于