ManagementObjectCollection.ManagementObjectEnumerator ManagementObjectCollection.ManagementObjectEnumerator ManagementObjectCollection.ManagementObjectEnumerator ManagementObjectCollection.ManagementObjectEnumerator Class

定義

コレクションの列挙子を表します。Represents the enumerator on the collection.

public: ref class ManagementObjectCollection::ManagementObjectEnumerator : IDisposable, System::Collections::IEnumerator
public class ManagementObjectCollection.ManagementObjectEnumerator : IDisposable, System.Collections.IEnumerator
type ManagementObjectCollection.ManagementObjectEnumerator = class
    interface IEnumerator
    interface IDisposable
Public Class ManagementObjectCollection.ManagementObjectEnumerator
Implements IDisposable, IEnumerator
継承
ManagementObjectCollection.ManagementObjectEnumeratorManagementObjectCollection.ManagementObjectEnumeratorManagementObjectCollection.ManagementObjectEnumeratorManagementObjectCollection.ManagementObjectEnumerator
実装

次の例では、 Win32_LogicalDiskクラスのすべてのインスタンスを列挙し、各インスタンスのDeviceID値を表示します。The following example enumerates through all of the instances of the Win32_LogicalDisk class, and displays the DeviceID value for each instance.

using System; 
using System.Management;
 
// This example demonstrates how to
// enumerate all logical disks 
// using the ManagementObjectEnumerator object.
class Sample_ManagementObjectEnumerator 
{
    public static int Main(string[] args) 
    { 
        ManagementClass diskClass = 
            new ManagementClass("Win32_LogicalDisk");
        ManagementObjectCollection disks = 
            diskClass.GetInstances();
        ManagementObjectCollection.ManagementObjectEnumerator
            disksEnumerator =
            disks.GetEnumerator();
        while(disksEnumerator.MoveNext()) 
        { 
            ManagementObject disk = 
                (ManagementObject)disksEnumerator.Current;
            Console.WriteLine(
                "Disk found: " + disk["deviceid"]);
        }
        return 0;
    }
}
Imports System.Management

' This sample demonstrates how to
' enumerate all logical disks
' using ManagementObjectEnumerator object.
Class Sample_ManagementObjectEnumerator
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer
        Dim diskClass As New _
            ManagementClass("Win32_LogicalDisk")
        Dim disks As ManagementObjectCollection = _
            diskClass.GetInstances()
        Dim disksEnumerator As _
        ManagementObjectCollection. _
            ManagementObjectEnumerator = _
            disks.GetEnumerator()
        While disksEnumerator.MoveNext()
            Dim disk As ManagementObject = _
            CType(disksEnumerator.Current, _
                ManagementObject)
            Console.WriteLine("Disk found: " & disk("deviceid"))
        End While
        Return 0
    End Function
End Class

プロパティ

Current Current Current Current

その列挙子が指している現在の ManagementBaseObject を取得します。Gets the current ManagementBaseObject that this enumerator points to.

メソッド

Dispose() Dispose() Dispose() Dispose()

オブジェクトと関連付けられたリソースを解放します。Releases resources associated with this object. このメソッドを呼び出した後に、このオブジェクトを使用しようとすると、ObjectDisposedException 例外がスローされます。After this method has been called, an attempt to use this object will result in an ObjectDisposedException exception being thrown.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

オブジェクトが保持しているリソースを解放します。Disposes of resources the object is holding. これはオブジェクトのデストラクターです。This is the destructor for the object. ファイナライザーは、デストラクター構文を使用して表します。Finalizers are expressed using destructor syntax.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)
MoveNext() MoveNext() MoveNext() MoveNext()

列挙子が列挙体の次のオブジェクトに移動したかどうかを示します。Indicates whether the enumerator has moved to the next object in the enumeration.

Reset() Reset() Reset() Reset()

列挙子をコレクションの先頭にリセットします。Resets the enumerator to the beginning of the collection.

ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

明示的なインターフェイスの実装

IEnumerator.Current IEnumerator.Current IEnumerator.Current IEnumerator.Current

コレクション内の現在のオブジェクトを取得します。Gets the current object in the collection.

適用対象