Why can I use the VBScript for each statement to iterate over the System.Collections.ArrayList oject, but not the Systems.Collections.SortedList ?
Given the following:
set aList = Server.CreateObject("System.Collections.ArrayList") aList.Add "a" aList.Add "b" aList.Add "c" for each item in aList ' do something next set sList = Server.CreateObject("System.Collections.SortedList") sList.Add "a", 1 sList.Add "b", 2 sList.Add "c", 3 for each item in sList ' do something next
Line
for each item in sList
glitch
An objectdoes not support this property or method *.
Through this property, I assume that they mean the _NewEnum property. But why does _NewEnum display an ArrayList but not a SortedList ? Both classes implement the IEnumberable interface, which, from the disassembly of mscorelib.dll appears to be the interface responsible for implementing the _NewEnum ( dispId of -4) property.
If someone can shed light on the various COM interactions of these similar classes, I would really appreciate it.
I know that I can use other properties set by SortedList to iterate over the collection. I am not asking how to iterate SortedList . I'm just asking why IEnumrable doesn't seem to be implemented in the interop version of SortedList when it is implemented in the interop version of ArrayList .
smarcaurele
source share