C# - metoda count
Dobrý večer,
Potřeboval bych poradit, jak by mohla vypadat metoda Count v této třídě, program mi s tímto běží, ale rád bych některé metody doplňil. Předem děkuji za odpoveďi.
class Seznam : IEnumerable
{
private ArrayList sz;
private int index;
public Seznam()
{
sz = new ArrayList();
index = -1;
}
public void reset()
{
index = -1;
}
public bool MoveNext()
{
index++;
if (index < sz.Count)
return true;
return false;
}
public Object Current
{
get
{
return sz[index];
}
}
public void Add(Hráč položka)
{
sz.Add(položka);
}
public Hráč this[int index]
{
get {return (Hráč)sz[index];}
set {sz[index] = value;}
}
public IEnumerator GetEnumerator()
{
int i = 0;
Hráč current = (Hráč)sz[i];
while (current != null)
{
yield return current;
i++;
if (i < sz.Count)
current = (Hráč)sz[i];
else
{
current = null;
}
}
}