The Clear() Method can be used to remove all the elements from the List.
using System.Collections.Generic; public class MyApplication { public static void Main(string[] args) { var x = new List<string>(){"Mohan", "Kriti", "Salim"}; x.Clear(); foreach (var data in x) { System.Console.WriteLine(data); } } }
So, in the above code we have created a List and initialised to the variable x.
var x = new List<string>(){"Mohan", "Kriti", "Salim"};
Below is how the values are positioned in the List,
Next, we have used the Clear() function that removes all the elements from the List making the List empty.
And we get an empty List as output,