ResXResourceReader.Close 方法

定義

釋放 ResXResourceReader 所使用的所有資源。

C#
public void Close ();

實作

範例

下列範例會顯示檔案的資源給控制台,然後使用 Close 方法來關閉讀取器,並使其資源可供其他進程使用。

C#
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();
   }
}

備註

呼叫 Close 可讓 重新配置 所使用的 ResXResourceReader 資源供其他用途使用。 如需 的詳細資訊 Close,請參閱 清除非受控資源

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9