Outofmemoryexception

Discussion in 'ASP .Net Web Controls' started by brandonjack007@gmail.com, Jul 20, 2007.

  1. Guest

    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.
     
    , Jul 20, 2007
    #1
    1. Advertising

  2. Teemu Keiski Guest

    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



    <> wrote in message
    news:...
    >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, Jul 22, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmlwdWwgSGFuZGE=?=

    Base Exception:System.OutOfMemoryException error message

    =?Utf-8?B?UmlwdWwgSGFuZGE=?=, Nov 17, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,036
    Natty Gur
    Nov 18, 2003
  2. =?Utf-8?B?amF6?=

    OutOfMemoryException

    =?Utf-8?B?amF6?=, Dec 10, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    365
    =?Utf-8?B?SmF6?=
    Dec 16, 2003
  3. Pyramis
    Replies:
    0
    Views:
    427
    Pyramis
    Jan 25, 2004
  4. =?Utf-8?B?U3Rhbg==?=

    Exception of type System.OutOfMemoryException is thrown

    =?Utf-8?B?U3Rhbg==?=, Feb 16, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    28,083
    Ken Cox [Microsoft MVP]
    Dec 28, 2004
  5. Versteijn
    Replies:
    7
    Views:
    20,224
    Denzien
    Mar 7, 2008
Loading...

Share This Page