- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
LinkedList RemoveFirst() Method in C#
Let’s say the following is our LinkedList with integer nodes.
int [] num = {29, 40, 67, 89, 198, 234}; LinkedList<int> myList = new LinkedList<int>(num);
Now, if you want to remove the first element from the list, then use the RemoveFirst() method.
myList.RemoveFirst();
Example
using System; using System.Collections.Generic; class Demo { static void Main() { int [] num = {29, 40, 67, 89, 198, 234}; LinkedList<int> myList = new LinkedList<int>(num); foreach (var n in myList) { Console.WriteLine(n); } // removing first node myList.RemoveFirst(); Console.WriteLine("LinkedList after removing the first node..."); foreach (var n in myList) { Console.WriteLine(n); } } }
Output
29 40 67 89 198 234 LinkedList after removing the first node... 40 67 89 198 234
Advertisements