For each loop for string (C#) : For Each « Language Basics « ASP.Net






For each loop for string (C#)

<%@ Page Language="C#" %>
<script runat="server">

void page_Load()
{
  string[] arrCities = new string[3];
  arrCities[0]=("A");
  arrCities[1]=("B");
  arrCities[2]=("C"); 

  foreach (string item in arrCities) {
    lblOut.Text += item + "<BR>";
  }
}

</script>
<html>
    <head>
    </head>
    <body>
        <form runat="server">
        <asp:Label runat="server" ID="lblOut"/><br/>
        </form>
    </body>
</html>

           
       








Related examples in the same category

1.For each loop: array (VB.net)
2.For each loop to reverse a string (VB.net)