Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
JScript
Enumerator Object (Windows Scripting - JScript)

Updated: March 2009

Enables enumeration of items in a collection.

enumObj = new Enumerator([collection]) 
enumObj

Required. The variable name to which the Enumerator object is assigned.

collection

Optional. Any Collection object.

Collections differ from arrays in that the members of a collection are not directly accessible. Instead of using indexes, as you would with arrays, you can only move the current item pointer to the first or next element of a collection.

The Enumerator object provides a way to access any member of a collection and behaves similarly to the For...Each statement in VBScript.

The following code shows the usage of the Enumerator object:

   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var e = new Enumerator(fso.Drives);
   var s = "";
   do
   {
      var x = e.item();

      s += x.DriveLetter;
      s += " - ";

      if (x.DriveType == 3)
         s += x.ShareName;
      else if (x.IsReady)
         s += x.VolumeName;
      else
         s += "[Drive not ready]";

      s += "<br />";
      
      e.moveNext();
   }
   while (!e.atEnd());

   document.write (s);

The Enumerator object has no properties.

Date

History

Reason

March 2009

Modified code example.

Information enhancement.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker