Tuesday, 29 May 2018

Stack Class generic Collection in C#





using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace ConsoleApplication32

{

    class Program

    {

        static void Main(string[] args)

        {





            Stack<string> s = new Stack<string>();

            s.Push("ALI");

            s.Push("Ahmed");

            s.Push("Basit");

            s.Push("zahid");

            s.Push("danish");

            s.Push("hasan");





            foreach (var item in s)

            {

                Console.WriteLine(item);

            }

            Console.WriteLine("Top Element is "+s.Peek());

            Console.WriteLine("press any key to pop element : ");

            Console.ReadKey();

            s.Pop();

            Console.WriteLine("Top Element is " + s.Peek());

            foreach (var item in s)

            {

                Console.WriteLine(item);

            }



            Console.ReadLine();

         



        }

    }

}


No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...