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 117 views
117 views asked Aug 16, 2021 by avibootz
2 answers 182 views
182 views asked Feb 21, 2017 by avibootz
2 answers 270 views
1 answer 182 views
1 answer 121 views
1 answer 125 views
125 views asked Aug 16, 2021 by avibootz
1 answer 173 views
173 views asked Jan 19, 2017 by avibootz
...