C# Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Foxy
    New Member
    • Nov 2006
    • 2

    C# Help

    Hi guys,
    Sorry to interrupt, but I need your help

    I can't seem to make this error go away:

    QuorumTest.Quor umTest.NoQuorum : System.Argument OutOfRangeExcep tion : Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    Below is a snippet of the code that is producing the error
    Ps: this error only occurs at runtime using NUnit
    for (int a = 0; a < x.Count; a +=2)
    {
    int current = x[a];
    int next = x[a + 1];
    int nextB = x[a + 2];
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by Foxy
    Hi guys,
    Sorry to interrupt, but I need your help

    I can't seem to make this error go away:

    QuorumTest.Quor umTest.NoQuorum : System.Argument OutOfRangeExcep tion : Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    Below is a snippet of the code that is producing the error
    Ps: this error only occurs at runtime using NUnit
    for (int a = 0; a < x.Count; a +=2)
    {
    int current = x[a];
    int next = x[a + 1];
    int nextB = x[a + 2];
    The people in the C forum will know better, but it looks like
    for (int a = 0; a < x.Count-2; a +=2)
    will keep you from stepping off the end of the array.
    Check out the C forum at:

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #3
      Originally posted by bartonc
      The people in the C forum will know better, but it looks like
      for (int a = 0; a < x.Count-2; a +=2)
      will keep you from stepping off the end of the array.
      Check out the C forum at:
      http://www.thescripts.com/forum/forum129.html
      Guys

      I've moved this in from the discussion forum. However, I believe it is now a double posting and can be deleted.

      Mary

      Comment

      Working...