ResourceReader.IDisposable.Dispose 메서드

정의

ResourceReader에서 사용하는 리소스를 해제합니다.Releases the resources used by the ResourceReader.

 virtual void System.IDisposable.Dispose() = IDisposable::Dispose;
void IDisposable.Dispose ();
Sub Dispose () Implements IDisposable.Dispose

구현

예제

다음 코드 예제에서는 파일의 리소스를 통해 이동 하 고 발견 되는 모든 키/값 쌍을 출력 합니다.The following code example moves through a file's resources and prints out all the key/value pairs it finds. 코드를 사용 하 여 theIDisposable.Dispose 메서드 종료는 ResourceReader 및 사용 하는 모든 리소스를 해제 합니다.The code then uses theIDisposable.Dispose method to shut down the ResourceReader and to release all resources used by it.

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 As IResourceReader = 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
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();
    }
}
using namespace System;
using namespace System::Resources;
using namespace System::Collections;
int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();

   // Create a resource reader for items.resources 
   // and get an enumerator to iterate through the file.
   IResourceReader^ reader = gcnew 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 the destructor is equivalent to calling Close.
   reader->~IResourceReader();
}

설명

사용 하는 리소스를 사용 하면 Dispose를 호출 합니다 ResourceReader 다른 용도로 다시 할당 될 수 있습니다.Calling Dispose allows the resources used by the ResourceReader to be reallocated for other purposes. Dispose에 대 한 자세한 내용은 참조 하세요. 관리 되지 않는 리소스 정리합니다.For more information about Dispose, see Cleaning Up Unmanaged Resources.

적용 대상