Foreach loop (C#) : ArrayList « Collections « ASP.NET Tutorial






<%@ Page %>
<script language="C#" runat="server">
  private void Page_Load(object sender, System.EventArgs e)
  {
    int i;
    System.Collections.ArrayList myList=new System.Collections.ArrayList();
    myList.Add("Zero");
    myList.Add("One");
    myList.Add("Two");
    myList.Add("Three");
    myList.Add("Four");
    myList.Add("Five");

    foreach (string number in myList)
    {
      Response.Write(number.ToString() + "<BR>");
    }
  }
</script>
<html>
  <body>
    <form id="form1" method="post" runat="server">
    </form>
  </body>
</html>








7.2.ArrayList
7.2.1.Add objects to ArrayList (C#)
7.2.2.Add objects to ArrayList (VB)
7.2.3.Foreach loop (C#)
7.2.4.Foreach loop (VB)
7.2.5.Using an ArrayList instead of an array (C#)
7.2.6.Using an ArrayList instead of an array (VB)
7.2.7.Using a custom strongly typed PersonList (C#)
7.2.8.Using a custom strongly typed PersonList (VB)
7.2.9.ArrayList with custom objects
7.2.10.Bind ArrayList to DropDownList