Initialize a new instance of Stack
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
class Program { static void Main(string[] args) { Stack colors = new Stack(); colors.Push("Red"); colors.Push("Green"); colors.Push("Blue"); colors.Push("Yellow"); Console.WriteLine("Stack Elements... "); foreach (string color in colors) { Console.WriteLine(color); } Console.ReadLine(); } } |
Output:
1 2 3 4 5 6 7 |
Stack Elements... Yellow Blue Green Red |