Link to home
Start Free TrialLog in
Avatar of zizi21
zizi21

asked on

foreach never executed

Hi,

I know this is strange but i have a foreach loop that works at one place and not in the other.

foreach(myclass my in list)
{
Console.Write("Hepp!");
}

this is never executed..could anyone pls help....
SOLUTION
Avatar of CMYScott
CMYScott
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
does your list actually contain anything?  does it contain any myclass objects?

Can you show us some more of your code?

AW
Avatar of zizi21
zizi21

ASKER

hi there,

thanks for replying.

It is not empty. to verify that, printed the data entered before entering the loop like this


Console.Write(" Name : {0}, Age:{1}",i.name;i.age);

and i got the results..
Avatar of zizi21

ASKER

is there any sample code that i could try foreach..


ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zizi21

ASKER

oh my gosh...i actually forgot to add the Add function at that area..thanks for looking into this..
Glad to be of assistance.

AW