Introducing Radical.sh

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

Converting String array to List in C#

The following code explains the conversion of string array to List and printing the values.

  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. string [] array = { "hi","welcome", "to", "forget code"};
  13. List<string> list = array.ToList();
  14. foreach (string item in list)
  15. {
  16. Console.WriteLine(item);
  17. }
  18. }
  19. }
  20. }


Output:

hi
welcome
to
forget code