This looks like C#, not JavaScript. :-)
If so, you should never use
ArrayList
. This type was rendered obsolete as early as by v.2.0, when generics were introduced. Formally, the class wasn't marked with
[Obsolete]
attribute only because there is nothing wrong with leaving it in some legacy code, but in new development it never makes any sense. Use
System.Collections.Generic.List<>
instead.
The iteration is done exactly as you did with your data rows:
System.Collections.Generic.List<SomeType> list = new System.Collections.Generic.List<SomeType>();
foreach (SomeType item in list) { }
This code can be shortened with
type inference:
var list = new System.Collections.Generic.List<SomeType>();
foreach (var item in list) { }
—SA