Cycling through a collection in compact framework- Possible?

  • Thread starter Thread starter RobGSCL
  • Start date Start date
R

RobGSCL

In vb6, objects were part of a collection and you could cycle through
the collection as follows:

For Each panel in Panels
do something
Next panel

Is there anythin like this for CF?
 
Yes, any class which implements IEnumerable (including all arrays) can be
used with a For Each loop.

Peter
 
Specifically for Panel controls of a Form f an additional typeguard is
necessary. It would result in (C#) code like:

foreach (Control c in f.Controls) {
if (c is Panel) {
Panelh = c as Panel;
// do something with h
}
}

Because not each Control is a Panel, the following code does not work:

foreach (Panel h in f.Controls) {
// do something with h
}
 
Back
Top