VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-get-the-number-of-elements-contained-in-collectiont/

⇱ C# | Get the number of elements contained in Collection<T> - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Get the number of elements contained in Collection<T>

Last Updated : 11 Jul, 2025
Collection<T>.Count property is used to get the number of elements actually contained in the Collection<T>. Syntax:
public int Count { get; }
Return Value: The number of elements actually contained in the Collection<T>. Below given are some examples to understand the implementation in a better way: Example 1: Output:
Count : 5
A
B
C
D
E
Example 2:
Output:
Count : 4
2
3
4
5
Note: Retrieving the value of this property is an O(1) operation. Reference:
Comment

Explore