How to create and use a StringCollection in C#

1 Answer

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

		Console.WriteLine(sc.Count); 
        
		foreach (string s in sc) {
            Console.WriteLine(s);
        }
	}
}



/*
run:

0
5
c#
c++
java
php
python

*/

 



answered May 9, 2020 by avibootz

Related questions

1 answer 122 views
1 answer 207 views
1 answer 153 views
1 answer 141 views
1 answer 186 views
1 answer 246 views
...