You need to follow
Richard's advice and make
myList
member of the
Stack
class. Then you could write, for instance
[updated, thanks to Richard Deeming]
public Stack(IEnumerable<T> collection)
{
myList = new List<T>(collection);
}
public T Pop()
{
int index = myList.Count-1;
if ( index < 0)
{
throw new InvalidOperationException("Empty stack");
}
T t = myList[index];
myList.RemoveAt[index];
return t;
}