Mega Code Archive

 
Categories / C# / Collections Data Structure
 

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]);     } }