Reader Level:
Articles

How to Delete C# List Items

By Mahesh Chand on Jul 06, 2012
How to delete all items in a C# List
  • 0
  • 0
  • 16004

Remove All Items

// Create a list of strings
List<string> AuthorList = new List<string>();
AuthorList.Add("Mahesh Chand");
AuthorList.Add("Praveen Kumar");
AuthorList.Add("Raj Kumar");
AuthorList.Add("Nipun Tomar");
AuthorList.Add("Dinesh Beniwal");

AuthorList.Remove("Mahesh Chand");

The Clear method removes all items from the List. The following code snippet removes all items by calling the Clear method. 

AuthorList.Clear();

Download Free book: Programming List with C#


Mahesh Chand

C# Corner founder, 10-times Microsoft MVP, technical author, and software architect. Mahesh authored his first book, A Programmer’s Guide to ADO.NET in C# with APress at the age of 25. C# Corner is a memb... Read more

COMMENT USING

Trending up