C# Program to Pop Elements From Stack Using Collection

Using this tutorial, we are going to run the script C# Program to Pop Elements From Stack Using Collection. Below you will find the possibilities for doing the task using this tutorial.

C# Program to Pop Elements From Stack Using Collection

C# Program to Pop Elements From Stack Using Collection

using System;
using System.Collections;

namespace ConsoleApplication1
{
    
    class Program
    {
        static void Main()
        {
            Stack S = new Stack(5);

            S.Push(10);
            S.Push(20);
            S.Push(30);
            S.Push(40);

            Console.WriteLine("Popped Element: " + S.Pop());
            Console.WriteLine("Popped Element: " + S.Pop());
            Console.WriteLine("Popped Element: " + S.Pop());
            Console.WriteLine("Popped Element: " + S.Pop());

        }
    }
}
Popped Element: 40
Popped Element: 30
Popped Element: 20
Popped Element: 10

Final Words

I hope this article is a C# Program to Pop Elements From Stack Using Collection Let me know in the comments section if you have any issues.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment