hi,
I thought i can use Item[] property to retrieve the value of array list at a particular index. In my case, I have created an object to ArrayList class and added some values to it. What i want is to retrieve the values randomly. The only problem is, I am unable to use the Item[] property as i am working with my project on .NET frame work. Please help me and solve the problem very soon.

Property to retreive value from the ArrayList object which supports the .NET frame work
aarongwood
return (Room) listRooms[random.Next(listRooms.Count)];
psmanii
ArrayList list = new ArrayList();
list.Add("foo");
list.Add("bar");
Console.WriteLine((string) list[1]); // prints bar
Intrepid00
I have a class name Room with constructor below
public Room(string description, string longDescription)
I have another class name Configurator with the following things
public
static Room medina, bishah;//like this I have many Room objects in my programArrayList listRooms =
new ArrayList();public
Room createRooms(){
medina =
new Room("Medina","Medina");bishah =
new Room("Bishah","Bishah");listRooms.Add(medina);
listRooms.Add(bishah);
}
//With the below method, I am unable to return the object of the Room which I need to return randomly.
public
Room getRandomRoom(){
System.Random random =
new System.Random(); int num = random.Next(11); return (Room)(listRooms.Item[num]);//Here i was unable}
By this you might have understood my problem. Please reply me as soon as possible.
Thank you once again.