Array initialization syntaxes
array-initialization-syntaxes.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
string[] birds = new string[]
{
"Brown Songlark",
"Cape Grassbird",
"Sedge Warbler"
};
string[] birds2 = new string[3];
birds2[0] = "Olivaceous Warbler";
birds2[1] = "Icterine Warbler";
birds2[2] = "Wood Warbler";
string[] birds3 = { "Wrentit", "Striated Yuhina", "Bearded Reedling", };
Label1.Text = "birds array.........<br />";
foreach (string s in birds)
{
Label1.Text += s + "<br />";
}
Label1.Text += "<br />birds2 array.........<br />";
foreach (string s in birds2)
{
Label1.Text += s + "<br />";
}
Label1.Text += "<br />birds3 array.........<br />";
foreach (string s in birds3)
{
Label1.Text += s + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - array initialization syntaxes</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
c# example - array initialization syntaxes
<br /> item in end of existing array
</h2>
<hr width="550" align="left" color="LightBlue" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br />
<asp:Button
ID="Button1"
runat="server"
Text="test array initialization syntaxes"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- How to add a new item in an existing array
- How to add a new item at the end of an existing array
- How to get the average of an int array elements
- How to convert a decimal array to a double array
- How to convert a string array to a string
- How to get dimension length of an array
- How to get difference between two arrays
- How to find an element from an array
- How to find all elements from an array that match the conditions
- How to perform foreach loop through an array elements