<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Globalization" %>
<html>
<head>
<title>C# Primer: foreach Statement</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
string html;
public void Page_Load ( Object sender, EventArgs e ) {
int myInt = 123456;
CultureInfo [ ] cultures = CultureInfo.GetCultures ( CultureTypes.InstalledWin32Cultures );
// write headers
html += "<table align='center' class='data' cellspacing=1>";
html += "<tr>";
html += "<th>Name</th>";
html += "<th>Native Name</th>";
html += "<th>English Name</th>";
html += "<th>Currency Format</th>";
html += "</tr>";
// list names and currency formats of available cultures
foreach ( CultureInfo culture in cultures ) {
html += "<tr>";
html += "<td>" + culture + "</td>";
html += "<td>" + culture.NativeName + "</td>";
html += "<td>" + culture.EnglishName + "</td>";
html += "<td align='right'>" + myInt.ToString ( "C", culture ) + "</td>";
html += "</tr>";
}
html += "</table>";
}
</script>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>C# Primer: <span class="hilite">foreach</span> Statement</h2></div>
<hr size=1 width=92%>
<center>
<h4>Enumerating the collection of supported cultures using <span class="hilite">System.Globalization.CultureInfo.GetCultures</span></h4>
<p><%= html %></p>
</center>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>