How to add an int array to a List in C#

1 Answer

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

public class Program
{
	public static void Main(string[] args)
	{
		int[] array = new int[] {2, 3, 6, 5, 30, 0};
        
        List<int> list = array.ToList(); 

		Console.WriteLine(string.Join(" ", list));
	}
}




/*
run:
   
2 3 6 5 30 0
   
*/

 



answered Jul 23, 2023 by avibootz

Related questions

1 answer 109 views
109 views asked Aug 16, 2021 by avibootz
2 answers 177 views
177 views asked Feb 21, 2017 by avibootz
2 answers 256 views
1 answer 172 views
1 answer 109 views
1 answer 114 views
114 views asked Aug 16, 2021 by avibootz
1 answer 166 views
166 views asked Jan 19, 2017 by avibootz
...