How to create a list with elements from an array in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		int[] array = new int[] { 3, 9, 0, 5, 1 };
        
        List<int> list = new List<int>(array);
		
		Console.WriteLine(string.Join(" ", list));
	}
}




/*
run:

3 9 0 5 1

*/

 



answered Mar 8, 2023 by avibootz

Related questions

1 answer 189 views
1 answer 209 views
1 answer 132 views
2 answers 254 views
...