using System.Collections.Generic;
public static void Main()
char[] extraGrade = { 'A', 'B', 'C' };
Stack<char> grades = new Stack<char>(extraGrade);
Console.WriteLine("---------Push() : To add items---------");
foreach (char grade in grades)
Console.WriteLine(grade);
Console.WriteLine("\n---------Peek() : To get highest item without removing it---------");
Console.WriteLine(grades.Peek());
Console.WriteLine("\n---------Contains() : Check and return Boolean if B exists in the collection---------");
Console.WriteLine(grades.Contains('B'));
Console.WriteLine("\n---------Count : To get total items---------");
Console.WriteLine(grades.Count);
Console.WriteLine("\n---------Pop() : To remove highest item---------");
Console.WriteLine(grades.Pop());
Console.WriteLine($"\nTotal items in collection : {grades.Count}");
Console.WriteLine("\n---------Return removed items from stack using While loop---------");
Console.WriteLine($"\nTotal items in collection before Pop() in while loop : {grades.Count}\n");
Console.WriteLine(grades.Pop());
Console.WriteLine($"\nTotal items in collection after Pop() in while loop: {grades.Count}");
grades = new Stack<char>(extraGrade);
Console.WriteLine("\n---------Clear() : Remove all the items---------");
Console.WriteLine($"\nTotal items in collection before Clear() : {grades.Count}");
Console.WriteLine($"\nTotal items in collection after Clear() : {grades.Count}");