public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Bank bank = new Bank();
//bank[0] = new Customer(1, "");
//bank[1] = new Customer(2, "");
//foreach (Customer c in bank)
//{
// MessageBox.Show(c.ToString());
//}
bank.Add(1, "abc");
bank.Add(2,"erf");
bank.Add(3, "test");
foreach (Customer c in bank)
{
MessageBox.Show(c.ToString());
}
}
}
public class Customer
{
public int i;
public string name;
public Customer(int i, string s)
{
this.i = i;
this.name = s;
}
public override string ToString()
{
return "CustID:" + i + ";CustName:" + name;
}
}
public class Bank:IEnumerable
{
private ArrayList al = new ArrayList();
public Customer this[int i]
{
get { return (Customer)this.al[i]; }
}
public int Add(int i, string s)
{
return al.Add(new Customer(i, s));
}
public int Count
{
get { return this.al.Count; }
}
#region IEnumerable Members
public IEnumerator GetEnumerator()
{
for (int i = 0; i < this.Count; i++)
{
yield return this[i];
}
}
#endregion
}
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Bank bank = new Bank();
//bank[0] = new Customer(1, "");
//bank[1] = new Customer(2, "");
//foreach (Customer c in bank)
//{
// MessageBox.Show(c.ToString());
//}
bank.Add(1, "abc");
bank.Add(2,"erf");
bank.Add(3, "test");
foreach (Customer c in bank)
{
MessageBox.Show(c.ToString());
}
}
}
public class Customer
{
public int i;
public string name;
public Customer(int i, string s)
{
this.i = i;
this.name = s;
}
public override string ToString()
{
return "CustID:" + i + ";CustName:" + name;
}
}
public class Bank:IEnumerable
{
private ArrayList al = new ArrayList();
public Customer this[int i]
{
get { return (Customer)this.al[i]; }
}
public int Add(int i, string s)
{
return al.Add(new Customer(i, s));
}
public int Count
{
get { return this.al.Count; }
}
#region IEnumerable Members
public IEnumerator GetEnumerator()
{
for (int i = 0; i < this.Count; i++)
{
yield return this[i];
}
}
#endregion
}