Results 1 to 5 of 5

Thread: [RESOLVED] Doesn't enter for loop

  1. #1

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Resolved [RESOLVED] Doesn't enter for loop

    Here is the loop code:

    Code:
                    
    for(int i = 1; i == args.Length;i++)
                    {
                    }
    When I breakpoint it, it goes to the i = 1 then the args.Length and then it just goes to the code under the loop?? Why?

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Doesn't enter for loop

    The loop will execute as long as the second expression (i == args.Length) evaluates to true.
    Is this the case? Does args.Length return 1? Even if that was the case, it would only execute the loop once.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Doesn't enter for loop

    args.Lenght return 8 when I use breakpoints....

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Doesn't enter for loop

    I assume you intend to iterate over the contents of args?
    Code:
    for(int i = 0; i < args.Length; i++)
    {
    }
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Doesn't enter for loop

    Now it works
    I had used == instead of <.

    Oh and I want to start from 1.

    Thx for helping :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width