ManagementObjectCollection.ManagementObjectEnumerator Class
.NET Framework 4
Represents the enumerator on the collection.
Namespace:
System.Management
Assembly: System.Management (in System.Management.dll)
The ManagementObjectCollection.ManagementObjectEnumerator type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Dispose | Releases resources associated with this object. After this method has been called, an attempt to use this object will result in an ObjectDisposedException exception being thrown. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Disposes of resources the object is holding. This is the destructor for the object. Finalizers are expressed using destructor syntax. (Overrides Object.Finalize().) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | MoveNext | Indicates whether the enumerator has moved to the next object in the enumeration. |
![]() | Reset | Resets the enumerator to the beginning of the collection. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
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; } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

