Outofmemoryexception

B

brandonjack007

I am using Arraylist to populate a drop down

I get outofmemoryexception at this line
for (iYear = 0; iYear <= oYearsList.Count - 1; iYear++)
{
sHtml.Append("<option value='" + oYearsList.Add(iYear)
+ "'>" + oYearsList.Add(iYear) + "</option>");
}

When I use:
for (iYear = 0; iYear <= oYearsList.Count - 1; iYear++)
{
sHtml.Append("<option value=2007>2007</option>");
}

I dont get this exception. Is there anything wrong the way I am using
the Add method of Arraylist.
 
T

Teemu Keiski

You are adding items to the ArrayList while you loop through the same
arraylist. Sounds like infinite loop to me, right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top