How to copy array of strings to StringCollection in C#

1 Answer

0 votes
using System;
using System.Collections.Specialized; 

public class Program
{
    public static void Main()
    {
		String[] arr = new String[] { "c#", "c++", "c", "php" }; 

		StringCollection sc = new StringCollection(); 
        sc.AddRange(arr); 
  
        Console.WriteLine(sc[0]); 
        Console.WriteLine(sc[2]); 
        Console.WriteLine(sc[3]); 
    }
}



/*
run:
 
c#
c
php
 
*/
  

 



answered May 8, 2020 by avibootz

Related questions

1 answer 213 views
1 answer 136 views
1 answer 143 views
1 answer 114 views
1 answer 194 views
1 answer 131 views
...