Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Converting Integer array to List in C#

The following code explains the conversion of integer array to list and printing the vales.

  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. namespace forgetCode
  7. {
  8. class program
  9. {
  10. public static void Main()
  11. {
  12. int[] array = { 1, 2, 3, 4, 5 };
  13. List<int> list = array.ToList();
  14. foreach (int i in list)
  15. {
  16. Console.WriteLine(i);
  17. }
  18. }
  19. }
  20. }


Output:
1
2
3
4
5