The "System.Collections.Generic" namespace in C# provides generic collection classes that allow type-safe storage and retrieval of objects. One of the most commonly used classes is "List", which is an implementation of a dynamic array.
The "List.Add" method is used to add an element to the end of the list. Here are a few examples:
Example 1:
List names = new List();
names.Add("John");
names.Add("Mary");
names.Add("Tom");
In this example, we create a new list of strings and add three names to it using the Add method.
Example 2:
List numbers = new List() { 1, 2, 3 };
numbers.Add(4);
In this example, we create a list of integers with initial values and then add a new number to it.