SiteMap  | About    

foreach loop

The foreach loop executes a block of code on each element in an array or a collection of items. When executing foreach loop it traversing items in a collection or an array .
  For Each [Item] In [Group]

Next [Item]

  foreach(Item in Group){
	// loopBody


  Item : The Item in the group

Group : The group containing items

The following ASP.NET program add an array of item to a Listbox using for..each loop.



<html xmlns="">
<head runat="server">
	<title>Untitled Page</title>
	<form id="form1" runat="server">
		<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
		<br />
		<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>

Click the following links to see full source code

C# Source Code
VB.NET Source Code
Default.aspx.vb (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.