Increment Public int. in for loop

Last post 01-15-2009 8:25 PM by mastermunkus. 4 replies.

Sort Posts:

  • Increment Public int. in for loop

    01-15-2009, 6:41 PM
    • Member
      117 point Member
    • mastermunkus
    • Member since 03-01-2008, 12:51 PM
    • Texas
    • Posts 58

    Newest update green

    Ok well still digging at this it occurs to me now what i need to do is wait for the events in my first

    iteration to fire then continue the foreach loop.

    Here is what I tried , problem is the events dont fire until the loop exits.

    Added to the end of my foreach

    for (int ii = 0; ii < 10; ii++)

    {

    System.Threading.
    Thread.Sleep(1000);

     

    }

    Here is my issue from the code below ( int I always ends up == 250 )

    What I am trying to achieve is  first time through the loop i = 250 , second  i = 500 , third i=750

    in another class I have Public int i;  

    Update --In Red--

    This gets me to 750 , However I now have the issue that i need to return the values seperately not just the end result of 750

    ArrayList list = new ArrayList();

    Class class = new Class();

    list.add("1");

    list.add("2");

    list.add("3");

    int i = 0 ;

    foreach(string s in list)

    {

    i + 250; 

    class.i = i;

    }

  • Re: Increment Public int. in for loop

    01-15-2009, 7:37 PM
    • Member
      586 point Member
    • ScottR27
    • Member since 02-14-2008, 3:27 PM
    • Maryland
    • Posts 104

     Hi Mastermunkus,

     Shouldn't your code be i += 250?

     Hope this helps,

    Scott

  • Re: Increment Public int. in for loop

    01-15-2009, 7:49 PM
    • Contributor
      7,249 point Contributor
    • whighfield
    • Member since 01-02-2006, 10:37 PM
    • Winterpeg, Manitoba
    • Posts 1,205

    Throwing your code completely out the window, what exactly are you trying to do?  Sleeping the current thread is probably not the best way to deal with problems you are having.

    Please mark the most helpful reply/replies as "Answer".

    - William
    http://thefrozencoder.ca
  • Re: Increment Public int. in for loop

    01-15-2009, 8:13 PM
    • Member
      117 point Member
    • mastermunkus
    • Member since 03-01-2008, 12:51 PM
    • Texas
    • Posts 58

    from my example class.i sets a Drawing x position on the screen,  for each string in my loop i need to offset that position so that the corespnding windows are not drawn on top of each other

  • Re: Increment Public int. in for loop

    01-15-2009, 8:25 PM
    • Member
      117 point Member
    • mastermunkus
    • Member since 03-01-2008, 12:51 PM
    • Texas
    • Posts 58
    scott that does work and it's the first thing i tried . however not for my end result  thanks though.
Page 1 of 1 (5 items)