C# Program to Clear All Elements From Stack

Hello, friend C# Program to Clear All Elements From Stack article We are going to know the topic clearly. The reason for that is that our friends have a lot of doubts. We hope the doubts will be resolved through this article. Let’s go inside this article.

C# Program to Clear All Elements From Stack

C# Program to Clear All Elements From Stack

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);

            S.Clear();

            Console.WriteLine("Now stack is empty");
            

        }
    }
}
Now stack is empty

Final Words

C# Program to Clear All Elements From Stack We hope the article has resolved your doubts. Also, let us know if you have any doubts and we will resolve your doubts.

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