Add Items
The Add method adds an item to a List. The following code snippet creates a List and adds items to it by using the Add method.
// Create a list
List<string> AuthorList = new List<string>();
// Add items using Add method
AuthorList.Add("Mahesh Chand");
AuthorList.Add("Praveen Kumar");
AuthorList.Add("Raj Kumar");
AuthorList.Add("Nipun Tomar");
AuthorList.Add("Dinesh Beniwal");
The AddRange method is used to add a collection of items. The following code snippet adds a collection of items to a List.
// Add a range of items
string[] authors = { "Mike Gold", "Don Box",
"Sundar Lal", "Neel Beniwal" };
AuthorList.AddRange(authors);