[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);
[/CODE]
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.
Checking last index of the array giving me a problem. VS2005 C#
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jan MontanoRank #1,295 · 1.3K reputationPosted Aug 5, 2007, 11:18 PM EDT
Try replacing rooms.Length() with rooms.Length instead. Length is called as a Property, and not as a Method.
Cheers,
Jan
mark adora2 reputationPosted Aug 5, 2007, 11:26 PM EDT
if (newrm == rooms.Length() -1)
To:
if (newrm == rooms.Length -1)
Array length's a property not a method :)
foo foolios8 reputationPosted Aug 6, 2007, 8:54 AM EDT