I am new to C#. This is a Unity project.
I initialize a room object from Room class with property map of type ArrayList like this:
Room room1 = new Room()
{
map = new ArrayList {
new ArrayList(new int[] { 1, 1 } ),
new ArrayList(new int[] { 1, 1 } ),
new ArrayList(new int[] { 1, 1 } )
}
}
Then I override ToString() method of the class Room
public override string ToString()
{
return "Room ["+map.Count+","+map[0].Count+"]";
}
Debug.Log(room1);
results in error:
'object' does not contain a definition for 'Count' and no accessible extension method 'Count' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
if I change ToString override as follows:
{
return "Room ["+map.Count+","+map[0]+"]";
}
then the result of
Debug.Log(room1);
is "Room [3,System.Collections.ArrayList]"
thus I came to conclusion that I get the error:
System.Collections.ArrayList does not contain a definition for 'Count'
What is going on?