Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to remove a node at the beginning of a Linked List
To remove a node at the beginning of a LinkedList, use the RemoveFirst() method.
string [] employees = {"Peter","Robert","John","Jacob"};
LinkedList<string> list = new LinkedList<string>(employees);
Now, to remove the first element, use the RemoveFirst() method.
list.RemoveFirst();
Let us see the complete example.
Example
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
string [] employees = {"Peter","Robert","John","Jacob"};
LinkedList<string> list = new LinkedList<string>(employees);
foreach (var emp in list) {
Console.WriteLine(emp);
}
// removing first node
list.RemoveFirst();
Console.WriteLine("LinkedList after removing first node...");
foreach (var emp in list) {
Console.WriteLine(emp);
}
}
}
Output
Peter Robert John Jacob LinkedList after removing first node... Robert John Jacob
Advertisements