Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Outofmemoryexception (http://www.velocityreviews.com/forums/t780045-outofmemoryexception.html)

brandonjack007@gmail.com 07-20-2007 06:24 PM

Outofmemoryexception
 
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.


Teemu Keiski 07-22-2007 02:21 PM

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

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net



<brandonjack007@gmail.com> wrote in message
news:1184955893.264471.47110@i38g2000prf.googlegro ups.com...
>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.
>





All times are GMT. The time now is 07:04 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57