[Mono-devel-list] Basic C# help

Eric Scott scottclansman at cwazy.co.uk
Fri Dec 10 16:21:03 EST 2004


Hey;
I'm newbie to C#, and have been getting an error in some simple code I'm 
doing.  The error is right after the following while loop executes:

  int totalrevenue = 0;
       user = 0;
       while(user <= revenue.GetLength(0)) {
       user ++;
       totalrevenue += revenue[user];
       }

Compiles fine, but when I run the exe file I get:

Unhandled Exception: System.IndexOutOfRangeException: Array index is out 
of range.
in <0x00255> Test:Main (string[])

I've fiddled a bit and found that all 50 cycles of the loop execute fine 
(The revenue array is 50 values long in one dimension), but before the 
next segment of the code executes (Just some Console.WriteLine 
commands), the exception occurs.

Sorry to post a newbie question here, but it seemed like the most 
fitting place.
      Cheerio,
             ES



More information about the Mono-devel-list mailing list