How to remove all the strings from StringCollection in C#

1 Answer

0 votes
using System;
using System.Collections.Specialized; 
                     
public class Program
{
    public static void Main()
    {
        StringCollection sc = new StringCollection(); 
   
        sc.Add("c#"); 
        sc.Add("c++"); 
        sc.Add("java"); 
        sc.Add("php"); 
        sc.Add("python"); 

        Console.WriteLine(sc.Count);

		sc.Clear(); 
		       
        Console.WriteLine(sc.Count);
    }
}
 
 
 
/*
run:
 
5
0
 
*/

 



answered May 9, 2020 by avibootz

Related questions

1 answer 163 views
1 answer 128 views
1 answer 141 views
1 answer 110 views
1 answer 188 views
...