CSharp - Collection Initialization on List

Description

Collection Initialization on List

Demo

using System;  
using System.Linq;  
using System.Collections.Generic;  
class Program//from  ww  w . j  a  v  a2 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