---
title: "I need to make a program by using the linklist in c#"  
description: "I need to make a program by using the linklist in c#"  
author: "Mark Devid"  
published: 2016-09-21  
updated: 2016-09-21  
canonical: https://www.mindstick.com/forum/34180/i-need-to-make-a-program-by-using-the-linklist-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# I need to make a program by using the linklist in c#

Hello Buddy

i need to make a [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) by using the linklist in c# for following [requirement](https://yourviews.mindstick.com/view/85169/becoming-an-influencer-requirement-of-skills-and-knowledge)

1. Adding the new [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) at the last of the [Linkedlist](https://www.mindstick.com/forum/159619/when-to-use-linkedlist-over-arraylist-in-c-sharp)

2. Adding the new string at the first of the Linkedlist

3. Adding the string after which do want to [insert](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net)

4. Adding the string before which do want to insert

5. Deleting the 1st element

6. Deleting the last element

7. DIsplay

8. terminate the program

Please help me.I would rreally appreciate your help.

Thanks

## Replies

### Reply by Abhishek Srivasatava

Hello Devid,\
I have created the program as per your request. \

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace Program{    class DisplayMessageForInput    {        public string GetInputResult()                {            Console.WriteLine("Please enter the string");            return Console.ReadLine();        }     }    class Program    {        static void Main(string[] args)        {            DisplayMessageForInput objDisplayInput = new DisplayMessageForInput();            int  opt = 0;            LinkedList<string> link1= new LinkedList<string>();            do            {                Console.WriteLine("Main Menu");                Console.WriteLine("1. Adding the new string at the last of the Linkedlist");                Console.WriteLine("2. Adding the new string at the first of the Linkedlist");                Console.WriteLine("3. Adding the string after which do want to insert");                Console.WriteLine("4. Adding the string before which do want to insert");                Console.WriteLine("5. Deleting the 1st element");                Console.WriteLine("6. Deleting the last element");                Console.WriteLine("7. DIsplay");                Console.WriteLine("0. terminate the program");                 Console.Write("Enter the Operation you want to perform : ");                opt = Convert.ToInt32(Console.ReadLine());                  switch (opt)                {                    case 1:                        link1.AddLast(objDisplayInput.GetInputResult());                        break;                   
                    case 2:
                        link1.AddFirst(objDisplayInput.GetInputResult());                        break;
                    case 3:                        Console.WriteLine("Enter the string after which do want to insert");                        string element = Console.ReadLine();                        LinkedListNode<string> node =link1.Find(element);                        link1.AddAfter(node,objDisplayInput.GetInputResult());                        break;
                    case 4:                        Console.WriteLine("Enter the string before which do want to insert");                        string g = Console.ReadLine();                        LinkedListNode<string> node1 = link1.Find(g);                        link1.AddBefore(node1,objDisplayInput.GetInputResult());                        break;                                      case 5:                        Console.WriteLine("Deleted element is {0} ",link1.First.Value);                        link1.RemoveFirst();                        break;                    case 6:                        Console.WriteLine("Deleted element is {0} ",link1.Last.Value);                        link1.RemoveLast();                        break;                    case 7:                        foreach (var linklist in link1)                        {                            Console.WriteLine("{0}", linklist);                        }                        break;                    default:                        if (opt != 0)                            Console.WriteLine("Invalid option \n");                        else                            Console.WriteLine("End of the program \n ");                         break;                }            } while (opt != 0);            Console.ReadLine();        }    }}
```

Please, let us know if anything else required.

\
\
\


---

Original Source: https://www.mindstick.com/forum/34180/i-need-to-make-a-program-by-using-the-linklist-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
