Box ints into ArrayList : ArrayList : Data Structure C# Examples


C# Examples » Data Structure » ArrayList »

 

Box ints into ArrayList









    
using  System;
using  System.Collections;

class  MainClass
{
    static  void  Main(string[]  args)
    {        
        ArrayList  myInts  =  new  ArrayList();
        myInts.Add(8);
        myInts.Add(3);
        myInts.Add(9);

        //  Unbox  first  item.
        int  firstItem  =  (int)myInts[0];

        //  Another  boxing  operation!
        Console.WriteLine("First  item  is  {0}",  firstItem);
    }
}
    
   
  
   



Output

First item is 8


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» ArrayList