By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,080 Members | 1,635 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,080 IT Pros & Developers. It's quick & easy.

Checking last index of the array giving me a problem. VS2005 C#

foolios
P: 5
Expand|Select|Wrap|Line Numbers
  1.         private void CreateMaze(int h, int w)
  2.         {
  3.             int r = h * w;
  4.             Room[] rooms = new Room[r];
  5.             Random rm = new Random();
  6.             int newrm = rm.Next(0, r);
  7.             int nrmcntr = newrm;
  8.             do
  9.             {
  10.                 rooms[newrm].rWall = "|";
  11.                 if (newrm == rooms.Length() -1)
  12.                 {
  13.                     newrm = 0;
  14.                 }
  15.                 newrm += 1;
  16.             } 
  17.             while (newrm != nrmcntr);
  18.  
At the line:
if (newrm == rooms.Length() -1)
I am trying to compare an integer to the last index of an array of room objects.

I get the error:
Method name expected
at that line but have no clue.

Thank you in advance for any explanations.
Aug 6 '07 #1
Share this Question
Share on Google+
1 Reply


P: 10
if (newrm == rooms.Length() -1)
should be rooms.Length - 1

~~
Aug 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.