Generic Collection : Generic Collection : Generic C# Examples


C# Examples » Generic » Generic Collection »

 

Generic Collection









    
using  System;
using  System.Collections.Generic;
using  System.Collections.ObjectModel;

class  MainClass
{
        static  void  Main()  {
                Collection<int>  numbers  =  new  Collection<int>();
                numbers.Add(  2  );
                numbers.Add(  9  );

                Collection<string>  strings  =  new  Collection<string>();
                strings.Add(  "J"  );
                strings.Add(  "B"  );

                Collection<  Collection<int>  >  colNumbers  =  new  Collection<Collection<int>>();
                colNumbers.Add(  numbers  );

                IList<int>  theNumbers  =  numbers;
                foreach(  int  i  in  theNumbers  )  {
                        Console.WriteLine(  i  );
                }
        }
}
    
   
  
   



Output

2
9


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic Collection