public int Pop() { Stack1 last = Stacks[Stacks.Count - 1]; int value = last.Pop(); if (last.size == 0) //need to check if stack is empty now -- so need a size attribute in the custom stack class { //since the last stack is empty .. remove it. Stacks.RemoveAt(Stacks.Count - 1); } return(value); }