Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Add items to ArrayList and use foreach loop to check

using System; using System.Collections; using System.Collections.Generic; using System.Text; class Program {     static void Main(string[] args) {         ArrayList baseballTeams = new ArrayList();         baseballTeams.Add("s");         baseballTeams.Add("r");         baseballTeams.Add("F");         foreach (string item in baseballTeams) {             Console.Write(item + "\n");         }     } }