Results 1 to 3 of 3

Thread: [RESOLVED] Checking last index of the array giving me a problem. VS2005 C#

  1. #1

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

    Resolved [RESOLVED] Checking last index of the array giving me a problem. VS2005 C#

    Code:
            private void CreateMaze(int h, int w)
            {
                int r = h * w;
                Room[] rooms = new Room[r];
                Random rm = new Random();
                int newrm = rm.Next(0, r);
                int nrmcntr = newrm;
                do
                {
                    rooms[newrm].rWall = "|";
                    if (newrm == rooms.Length() -1)
                    {
                        newrm = 0;
                    }
                    newrm += 1;
                } 
                while (newrm != nrmcntr);
    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.

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

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

    Hi there,
    The compiler is expecting a Method due to the addition of the "()" after the array's Length property. Just remove the "()"


  3. #3

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

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

    Thank you so much

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