foreach infinite recursion...ArrayList with a null value?

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
Hey C9!

I have a foreach loop that looks kinda like this:


foreach(string x in roles)
{
***//Do some processing
}


ArrayList roles is assigned to like such:

roles.AddRange((string[])Roles.GetRolesForUser(username));

(Basically, I'm using ASP.NET Roles and looping through them later on. I'm not using a regular array and a for loop because I don't want a fixed array)

My problem is,when I run the foreach loop, my Server goes funky, and VS claims that foreach loop is infinitely recursing.

When I step through that loop, I see the Arraylist roles having a definite Count of 6 items, each item being a valid string. I also notice that the foreach IS in fact running infinitely. One thing interesting is, x at one point is "null," and right after the null is processed, the foreach loop starts over again. So, I'm thinking that null is the culprit, although, I do not see null in the Arraylist in reflector.

What could be the problem?



More...

View All Our Microsft Related Feeds
 
Back
Top