次の方法で共有


ResourceReader.IDisposable.Dispose メソッド

ResourceReader によって使用されているリソースを解放します。

Private Sub Dispose() Implements IDisposable.Dispose
[C#]
void IDisposable.Dispose();
[C++]
private: void IDisposable::Dispose();
[JScript]
private function IDisposable.Dispose();

実装

IDisposable.Dispose

解説

Dispose を呼び出すと、 ResourceReader によって使用されているリソースを他の目的のために再割り当てできます。 Dispose の詳細については、「 アンマネージ リソースのクリーンアップ 」を参照してください。

使用例

 
Imports System
Imports System.Resources
Imports System.Collections

Public Class ReadResources
   
    Public Shared Sub Main(args() As String)
        ' Create a resource reader for items.resources
        ' and get an enumerator to iterate through the file.
        Dim reader = New ResourceReader("items.resources")
        Dim en As IDictionaryEnumerator = reader.GetEnumerator()
      
        ' Iterate through the file, printing the key and value pairs.
        While en.MoveNext()
            Console.WriteLine()
            Console.WriteLine("Name: {0}", en.Key)
            Console.WriteLine("Value: {0}", en.Value)
        End While

        ' Clean up all resources associated with the reader.
        ' Calling Dispose is equivalent to calling Close.
        reader.Dispose()
    End Sub

End Class

[C#] 
using System;
using System.Resources;
using System.Collections;
 
public class ReadResources 
{
    public static void Main(string[] args) 
    {
        // Create a resource reader for items.resources
        // and get an enumerator to iterate through the file.
        IResourceReader reader = new ResourceReader("items.resources");
        IDictionaryEnumerator en = reader.GetEnumerator();
      
        // Iterate through the file, printing the key/value pairs.
        while (en.MoveNext()) 
        {
            Console.WriteLine();
            Console.WriteLine("Name: {0}", en.Key);
            Console.WriteLine("Value: {0}", en.Value);
        }
      
        // Clean up all resources associated with the reader.
        // Calling Dispose is equivalent to calling Close.
        reader.Dispose();
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;
using namespace System::Resources;
using namespace System::Collections;


int main() {
    String* args[] = Environment::GetCommandLineArgs();
    // Create a resource reader for items.resources
    // and get an enumerator to iterate through the file.
    IResourceReader* reader = new ResourceReader(S"items.resources");
    IDictionaryEnumerator* en = reader->GetEnumerator();

    // Iterate through the file, printing the key/value pairs.
    while (en->MoveNext()) {
        Console::WriteLine();
        Console::WriteLine(S"Name: {0}", en->Key);
        Console::WriteLine(S"Value: {0}", en->Value);
    }

    // Clean up all resources associated with the reader.
    // Calling Dispose is equivalent to calling Close.
    reader->Dispose();
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ResourceReader クラス | ResourceReader メンバ | System.Resources 名前空間