CSharp - Collection Initialization on List

Description

Collection Initialization on List

Demo

using System;  
using System.Linq;  
using System.Collections.Generic;  
class Program/*w w  w  .  j a v  a2  s .co  m*/
{
    static void Main(string[] args)
    {
       List<string> names = new List<string> { "Python", "Java", "Javascript" };  
       foreach(string president in names)  
       {  
           Console.WriteLine(president);  
       }  
    }
}

Result

Related Topic