VOOZH
about
URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-remove-all-elements-from-the-collectiont/
⇱ C# | Remove all elements from the Collection<T> - GeeksforGeeks
👁 geeksforgeeks
Courses
Tutorials
Interview Prep
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
C# | Remove all elements from the Collection<T>
Last Updated :
11 Jul, 2025
Collection<
T
>.Clear
method is used to remove all elements from the Collection<
T
>.
Syntax:
public void Clear ();
Below given are some examples to understand the implementation in a better way:
Example 1:
Output:
Count : 5 A B C D E Count : 0
Example 2:
Output:
Count : 4 2 3 4 5 Count : 0
Note:
Count is set to zero, and references to other objects from elements of the collection are also released.
This method is an O(n) operation, where n is Count.
Reference:
https://learn.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.collection-1.clear?view=netframework-4.7.2
Comment
Article Tags:
Article Tags:
C#
CSharp-method
CSharp-Collections.ObjectModel-Namespace
CSharp-Collection-Class
Explore
Basics
Introduction
3 min read
.NET Framework
5 min read
Architecture and Component Stack
6 min read
C# Hello World
2 min read
CLR
4 min read
Fundamentals
Identifiers
2 min read
Data Types
3 min read
Variables
2 min read
Constants & Literals
4 min read
Operators
7 min read
Keywords
5 min read
Control Statements
Decision Making
4 min read
Switch Statement
4 min read
Loops
4 min read
Jump Statements
4 min read
OOP Concepts
Classes and Objects
4 min read
Constructors
5 min read
Inheritance
3 min read
Encapsulation
2 min read
Abstraction
4 min read
Methods
Methods
3 min read
Method Overloading
4 min read
Function Parameters
3 min read
Method Overriding
7 min read
Anonymous Method
2 min read
Arrays
Arrays
5 min read
Jagged Arrays
5 min read
Array Class
5 min read
Sort an Array
3 min read
Rank of an Array
2 min read
ArrayList
ArrayList
6 min read
ArrayList Class
4 min read
Array vs ArrayList
2 min read
String
Strings
6 min read
Verbatim String Literal
5 min read
String Class
9 min read
StringBuilder
2 min read
String vs StringBuilder
3 min read
Tuple
Tuple
6 min read
Tuple Class
3 min read
ValueTuple
7 min read
ValueTuple Struct
4 min read
Indexers
Indexers
5 min read
Multidimensional Indexers
5 min read
Overloading of Indexers
3 min read
Properties
Properties
4 min read
Restrictions on Properties
5 min read
Collections & Generics
Collections
5 min read
Collection Class
3 min read
Generics and Generic Classes
3 min read
List Implementation
6 min read
SortedList
7 min read
HashSet
4 min read
SortedSet
4 min read
Dictionary
4 min read
SortedDictionary
7 min read
Hashtable
6 min read
Stack
6 min read
Queue
6 min read
LinkedList
5 min read
ASP.NET Interview Q&A
15+ min read
Courses
DSA Self Paced
2 min read
DSA and System Design
2 min read