Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,128 questions

40,777 answers

573 users

How to copy StringCollection to array 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"); 

		String[] arr = new String[sc.Count];
 		
		sc.CopyTo(arr, 0); 
		
		foreach (string s in arr) {
            Console.WriteLine(s);
        }
        
	}
}



/*
run:

c#
c++
java
php
python

*/

 





answered May 9, 2020 by avibootz

Related questions

1 answer 73 views
1 answer 68 views
1 answer 22 views
1 answer 82 views
...