
- 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 remove an element from Array List in C#?
Declare a new ArrayList and add elements to it.
ArrayList arr = new ArrayList(); arr.Add( "One" ); arr.Add( "Two" ); arr.Add( "Three" ); arr.Add( "Four" );
Now let’s say you need to remove the element “Three”. For that, use the Remove() method.
arr.Remove("Three");
The following is the complete example to remove an element from ArrayList −
Example
using System; using System.Collections; class Demo { static void Main() { ArrayList arr = new ArrayList(); arr.Add( "One" ); arr.Add( "Two" ); arr.Add( "Three" ); arr.Add( "Four" ); Console.WriteLine("ArrayList..."); foreach(string str in arr) { Console.WriteLine(str); } arr.Remove("Three"); Console.WriteLine("ArrayList after removing an element..."); foreach(string str in arr) { Console.WriteLine(str); } Console.ReadLine(); } }
Output
ArrayList... One Two Three Four ArrayList after removing an element... One Two Four
- Related Articles
- How to remove an element from an array in Java
- How to remove an element from a list in Python?
- How to remove an element from a Java List?
- How to remove every Nth element from an array JavaScript?
- How to delete/remove an element from a C# array?
- How to remove an element from a list by index in Python?
- Java Program to remove an element from List with ListIterator
- Java Program to Remove Duplicates from an Array List
- MongoDB query to match and remove element from an array?
- How do I remove a particular element from an array in JavaScript
- How to remove a specific element from array in MongoDB?
- How to remove an element from a doubly-nested array in a MongoDB document?
- How to remove an element from ArrayList in Java?
- How to remove Specific Element from a Swift Array?
- How to remove an array element by its index in MongoDB?

Advertisements