
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
How to pop the first element from a C# List?
To pop the first element in the list, use the RemoveAt() method. It eliminates the element from the position you want to remove the element.
Set the list
List<string> myList = new List<string>() { "Operating System", "Computer Networks", "Compiler Design" };
Now pop the first element using RemoveAt(0)
myList.RemoveAt(0);
Let us see the complete example.
Example
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List<string> myList = new List<string>() { "Operating System", "Computer Networks", "Compiler Design" }; Console.Write("Initial list..."); foreach (string list in myList) { Console.WriteLine(list); } Console.Write("Removing first element from the list..."); myList.RemoveAt(0); foreach (string list in myList) { Console.WriteLine(list); } } }
Output
Initial list... Operating System Computer Networks Compiler Design Removing first element from the list... Computer Networks Compiler Design
- Related Articles
- How to pop-up the first element from a Python tuple?
- How to extract only first sub-element from a list in R?
- How to extract first n values from each element in an R list?
- How to get the first element of the List in Java?
- How to remove an element from a Java List?
- How to extract first value from a list in R?
- How to select a random element from a C# list?
- How to remove an element from a list in Python?
- How to find the element from a Python list with a maximum value?
- How to find the element from a Python list with a minimum value?
- Select first element of a commaseparated list in MySQL?
- How to delete last element from a List in C++ STL
- How to exclude first and second element from jQuery selector?
- C# Program to get the first three elements from a list
- Golang Program to delete the first node from a linked list.

Advertisements