VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-add-an-object-to-the-end-of-collectiont/

⇱ C# | Add an object to the end of Collection<T> - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Add an object to the end of Collection<T>

Last Updated : 11 Jul, 2025
Collection<T>.Add(T) method is used to add an object to the end of the Collection<T>. Syntax :
public void Add (T item);
Here, item is the object to be added to the end of the Collection<T>. The value can be null for reference types. Below given are some examples to understand the implementation in a better way: Example 1: Output:
The number of elements in myColl are : 5
The elements in myColl are : 
A
B
C
D
E
Example 2:
Output:
The number of elements in myColl are : 4
The elements in myColl are : 
2
3
4
5
Note:
  • Collection<T> accepts null as a valid value for reference types and allows duplicate elements.
  • This method is an O(1) operation.
Reference:
Comment

Explore