Stack Push Operation on Link List C#

Now i will be presenting the implementation  of stack on linked list.

Every body would be aware of coding stack on arrays which is a very simple step. But some people find difficulty while implementing the stack on link list.
First you should know what is a stack, Stack or LIFO Stack (last in first out) is a type of data structure which is use to put the values in a proper from and is implemented in various computer programs, It contains one entry and exit point from where values can push in or pop out of the Stack.
*/for more details on stack you can view stack description at (*/

Link List is also another form of data structure which contains item and it’s linking next node.
*/for more details on stack you can view stack description at (*/

So i will implementing the stack push operation in link list.
It will be done through a C# class which i have named test_Stack.
It contains the private variable first which will be null.
A private inner class Node is used to declare string item and next node.
A bool method is just used to check if the first node is empty .

class test_Stack
        private Node first = null;
        private class Node
            public string item ;
            public Node next;
       public bool check()
            return first == null;
       public void push(string item)
            Node oldfirst = first;
            first = new Node();
            first.item = item;
   = oldfirst;
You can call the method in the main function to check if the class is working fine. By just creating an object and calling the method.

static void Main(string[] args)
            test_Stack test1 = new test_Stack();
            string item=null;
            int i=2;
            while (i != 0)
                Console.WriteLine(“enter the test value”);
                item = Console.ReadLine();


8 thoughts on “Stack Push Operation on Link List C#

  1. Hi there very nice blog!! Guy .. Beautiful .
    . Wonderful .. I will bookmark your blog and take the feeds
    additionally? I am happy to search out a lot of useful information right here in the put up, we need
    develop more strategies on this regard, thank you for sharing.

    . . . . .

  2. Very nice, that was an easy to read and understand post and I really wish I had read that before I spent half hour trying to write my function definition using the linked implementation….you wouldn’t be able to help understand how to describe an algorithm in terms of big O? would you?

  3. Hi there, i liked your university management system project. is it possible to provide the source code of your project to me? If possible please mail me It would be a great help for me. Thanks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s