counting multiples in a c# arraylist
Hi,
i have fixed the issues in your bug and left for you to analyze what i have modified, analyze it and try to think why this was done.
using System;
using System.Collections;
class contact
{
public string Name
{
get
{
return name;
}
set
{
name=value;
}
}
string name;
public string Status
{
get
{
return status;
}
set
{
status=value;
}
}
string status;
public void Setdate ( string status, string name)
{
this.status = status;
this.name = name;
}
}
class entry
{
public static void Main()
{
contact obj1 = new contact();
contact obj2 = new contact();
ArrayList container= new ArrayList(101);
obj1.Name = "John";
obj1.Status = "Online";
container.Add(obj1); // I want to pass it into ArrayList, but exception
obj2.Name = "Peter";
obj2.Status = "OFFLINE"; // Now i create another obj and want to store into the ArrayList
container.Add(obj2); // so now should have multiple object contain inside the ArrayList?
for (int i=0; i<container.Count; i++)
Console.WriteLine("Name = {0} Status = {1} ", ((contact)container).Name,((contact)container).Status); // How do i print it out?
}
}