C# Program to Peek Elements From Stack Using Collection

In this tutorial, we will learn C# Program to Peek Elements From Stack Using Collection

C# Program to Peek Elements From Stack Using Collection

C# Program to Peek 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("Peeked Element: " + S.Peek());
            Console.WriteLine("Peeked Element: " + S.Peek());
            Console.WriteLine("Peeked Element: " + S.Peek());
            Console.WriteLine("Peeked Element: " + S.Peek());

        }
    }
}
Peeked Element: 40
Peeked Element: 40
Peeked Element: 40
Peeked Element: 40

Final Words

I hope this article is a C# Program to Peek 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