Online C# Compiler

using System; using System.Collections.Generic; public class Demo { public static void Main(){ Stack<int> stack = new Stack<int>(); stack.Push(10); stack.Push(20); stack.Push(30); stack.Push(40); stack.Push(50); Console.WriteLine("Displaying the stack..."); foreach(int val in stack){ Console.WriteLine(val); } int[] intArr = new int[10]; stack.CopyTo(intArr, 2); Console.WriteLine("Displaying the array..."); foreach(int val in intArr){ Console.WriteLine(val); } } }