Results 1 to 8 of 8

Thread: c# help

  1. #1

    Josh's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    415
    Thanks
    24
    Thanked 371 Times in 141 Posts


    Downloads
    82
    Uploads
    6
    Mentioned
    117 Post(s)
    Time Online
    17 d 1 h 30 m
    Avg. Time Online
    13 m
    Rep Power
    7

    c# help

    @Zachafer

    http://pastebin.com/tPKf7Yre

    I dont get why that doesnt work.

    Its for a kad feeder. Never really worked in c# before. lsttemp is a list containing both the ids and item names. And lstignore is the items to ignore.

    I believe the problem is when it deletes the last thing in the list.


    ^Thats the error I get.

    And this line is highlighted:
    Last edited by Josh; 12-11-2012 at 01:27 AM.

  2. #2
    Saiyan Race





    Infamous Joe's Avatar
    Join Date
    Dec 2011
    Gender
    Location
    Hyperbolic Time Chamber
    Age
    26
    Posts
    9,758
    Thanks
    2,780
    Thanked 16,245 Times in 4,239 Posts


    Downloads
    23
    Uploads
    36
    Mentioned
    2986 Post(s)
    Time Online
    293 d 23 h 31 m
    Avg. Time Online
    3 h 44 m
    Rep Power
    10
    Gamer IDs

    Gamertag: Infam0us Joe Steam ID: infamousjoe
    InvalidArgument=Value of '8' is not valid for 'index'.


    There is no 9th item in your list

  3. #3

    Josh's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    415
    Thanks
    24
    Thanked 371 Times in 141 Posts


    Downloads
    82
    Uploads
    6
    Mentioned
    117 Post(s)
    Time Online
    17 d 1 h 30 m
    Avg. Time Online
    13 m
    Rep Power
    7
    Quote Originally Posted by Infamous Joe View Post
    InvalidArgument=Value of '8' is not valid for 'index'.


    There is no 9th item in your list
    Any clue how to fix it? I know the problem, but Im not too sure about how to fix it. Right now its running with 9 items in the list to begin with. But every time it does it 1 is removed (Right now its only unbuyables showing up for kads)

  4. #4

    Join Date
    Nov 2012
    Gender
    Location
    Cyberspace
    Posts
    17
    Thanks
    0
    Thanked 7 Times in 6 Posts


    Downloads
    4
    Uploads
    0
    Mentioned
    5 Post(s)
    Time Online
    11 h 6 m
    Avg. Time Online
    N/A
    Rep Power
    6
    The root of the problem is that your inner loop and outer loop should be reversed. Since you can possibly change the list items from the outer loop while you are still running the inner loop, removing the last item from the list will cause problems.

    Here are two different solutions, the first one is simpler, the second reverses your loops so the code should work without error.

    This first example takes advantage of ListBox.FindString which does an efficient search of the list and uses only a single for loop of the ignore list.



    The second example is similar to what you had but is fixed by swapping the two loops around so its safe to change the first list in the second loop.



    Hope that helps.

  5. The Following 2 Users Say Thank You to drew010 For This Useful Post:

    Infamous Joe (12-11-2012),Josh (12-11-2012)

  6. #5

    Josh's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    415
    Thanks
    24
    Thanked 371 Times in 141 Posts


    Downloads
    82
    Uploads
    6
    Mentioned
    117 Post(s)
    Time Online
    17 d 1 h 30 m
    Avg. Time Online
    13 m
    Rep Power
    7
    That works perfect. Thanks for the help.

  7. #6
    Little Brother


    Zachafer's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    1,206
    Thanks
    723
    Thanked 1,392 Times in 651 Posts


    Downloads
    81
    Uploads
    17
    Mentioned
    497 Post(s)
    Time Online
    21 d 17 h 35 m
    Avg. Time Online
    16 m
    Rep Power
    15
    You should probably use a custom class (ie Item.cs) for storing Item Names with corresponding IDs.

  8. #7

    Josh's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    415
    Thanks
    24
    Thanked 371 Times in 141 Posts


    Downloads
    82
    Uploads
    6
    Mentioned
    117 Post(s)
    Time Online
    17 d 1 h 30 m
    Avg. Time Online
    13 m
    Rep Power
    7
    I like my way.

  9. #8
    Saiyan Race





    Infamous Joe's Avatar
    Join Date
    Dec 2011
    Gender
    Location
    Hyperbolic Time Chamber
    Age
    26
    Posts
    9,758
    Thanks
    2,780
    Thanked 16,245 Times in 4,239 Posts


    Downloads
    23
    Uploads
    36
    Mentioned
    2986 Post(s)
    Time Online
    293 d 23 h 31 m
    Avg. Time Online
    3 h 44 m
    Rep Power
    10
    Gamer IDs

    Gamertag: Infam0us Joe Steam ID: infamousjoe

    c# help

    Lol @Zachafer knows his shit

  10. The Following User Says Thank You to Infamous Joe For This Useful Post:

    Zachafer (12-27-2012)

Posting Permissions

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