Subscribe to our YouTube Channel for more Videos

How to convert Array to List in C#?


Want to convert array of strings to List of strings in C# ? . Below is a sample code to illustrate this.

How to convert Array to List in C#?

using System;
using System.Collections.Generic;
using System.Linq;

namespace GinktageConsoleApp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string[] inputStr = { "Ginktage.com", "Technology Blog", " Dotnet Prohgramming" };
            List<string> list = inputStr.ToList();
            foreach (var item in list)
                Console.WriteLine(item);
            Console.ReadLine();
        }
    }
}

image

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.