How do you check whether a Stack<T> is empty?
Use the Count property.
if (stack.Count == 0)
Console.WriteLine("Stack is empty");
Unlike some languages, C# stacks do not provide an IsEmpty property.
Follow:
Use the Count property.
if (stack.Count == 0)
Console.WriteLine("Stack is empty");
Unlike some languages, C# stacks do not provide an IsEmpty property.
Follow: