如何使用索引器???????
using System;using System.Collections;
namespace _176
{
/// <summary>
/// checks 的摘要说明。
/// </summary>
public class TravelerCheck
{
private int number;
private decimal amount;
public int Number
{
get
{
return number;
}
}
public decimal Amount
{
get
{
return amount;
}
}
public TravelerCheck(int checkNumber,decimal checkAmount)
{
number=checkNumber;
amount=checkAmount;
//
// TODO: 在此处添加构造函数逻辑
//
}
}
public class Checks
{
private Queue checkQueue;
public object[] checkList;
public int account
{
get
{
return checkQueue.Count;
}
}
public Checks()
{
checkQueue=new Queue();
}
public TravelerCheck this [int index]
{
get
{
return (TravelerCheck)checkList[index];
}
}
public void Add(TravelerCheck a)
{
checkQueue.Enqueue(a);
checkList=checkQueue.ToArray();
}
public void Remove()
{
if(checkQueue.Count>0)
{
checkQueue.Dequeue();
checkList=checkQueue.ToArray();
}
}
}
}