How to Add item to the beginning of List in C# ?

If you want to add or insert an item to the beginning of the List in C# , you can use the Insert method defined in the collection as shown below.

How to Add item to the beginning of List in C# ?

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

namespace ACCode
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> LstItems = new List<string>();
            LstItems.Add(“One”);
            LstItems.Add(“Two”);
            LstItems.Add(“Three”);
            LstItems.Add(“Four”);

            // Adds an item to the beginning of the list
            LstItems.Insert(0,”Five”);

            foreach (var item in LstItems)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }      
    }
}

%d