
- 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 item from an ArrayList in C#?
Firstly, set a a new ArrayList and add elements to it.
ArrayList arr = new ArrayList(); arr.Add( "Jones" ); arr.Add( "Tom" ); arr.Add( "Henry" );
Now let’s remove the item “Tom”. For that, use the Remove() method.
arr.Remove("Tom");
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( "Jones" ); arr.Add( "Tom" ); arr.Add( "Henry" ); Console.WriteLine("Initial 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
Initial ArrayList... Jones Tom Henry ArrayList after removing an element... Jones Tom Henry
- Related Articles
- How to remove an item from an ArrayList in Kotlin?
- How to add an item to an ArrayList in C#?
- How to insert an item in ArrayList in C#?
- C# program to remove an item from Set
- Remove an item from a Hashtable in C#
- How to add an item to an ArrayList in Kotlin?
- How to remove duplicates from an ArrayList in Java?
- How to remove an element from ArrayList in Java?
- How to remove an item from a C# list by using an index?
- How to remove a SubList from an ArrayList in Java?
- How to remove an element from ArrayList or, LinkedList in Java?
- How to remove an item from JavaScript array by value?
- Remove duplicate items from an ArrayList in Java
- How to check if ArrayList contains an item in Java?
- How to remove the redundant elements from an ArrayList object in java?

Advertisements