CSharp - Collection Initialization on List

Description

Collection Initialization on List

Demo

using System;  
using System.Linq;  
using System.Collections.Generic;  
class Program/* w  ww . j a va  2 s  . c o  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