static void Main(string[] args) { ObjectStack stack = new ObjectStack(); stack.Push(5); stack.Push("time to sleep"); Console.WriteLine(stack.Count()); stack.Push(DateTime.Now); stack.Push(21); var first = stack.Pop(); Console.WriteLine(first); var second = stack.Peek(); Console.WriteLine(second); TypeStack <int> typeStack = new TypeStack <int>(); typeStack.Push(3); typeStack.Push(5); typeStack.Push(7); typeStack.Push(9); typeStack.Push(11); typeStack.Push(13); Console.WriteLine(typeStack.Count()); stack.GetCapacity(); typeStack.GetCapacity(); Console.ReadLine(); }
public static void GetCapacity(this ObjectStack stack) { int capacity = stack.Count(); Console.WriteLine($"your free capacity is: {ObjectStack.maxSize - capacity}"); }