Using foreach to loop through ArrayList and use Indexer of ArrayList : ArrayList : Collections Data Structure C# Source Code


Custom Search

C# Source Code » Collections Data Structure » ArrayList »

 

Using foreach to loop through ArrayList and use Indexer of ArrayList








    

 
using System;
using System.Collections;

class CollectionsDemo {
    public static void Main(String[] args) {

        ArrayList PokerPlayers = new ArrayList(3);
        PokerPlayers.Add("J");
        PokerPlayers.Add("M");
        PokerPlayers.Add("A");
        PokerPlayers.Add("J");

        foreach (String Player in PokerPlayers) {
            Console.WriteLine(Player);
        }

        PokerPlayers[0] = "A";
        System.Console.WriteLine(PokerPlayers[0]);
    }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Collections Data Structure
» ArrayList