Array clone
array-clone.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
string[] birds = new string[]
{
"Green Heron",
"Grey Heron",
"Goliath Heron"
};
string[] clonedbirds = birds.Clone() as string[];
Label1.Text = "birds array.........<br />";
foreach (string s in birds)
{
Label1.Text += s + "<br />";
}
Label1.Text += "<br />cloned birds array.........<br />";
foreach (string s in clonedbirds)
{
Label1.Text += s + "<br />";
}
clonedbirds[1] = "Great Blue Heron";
birds[2] = "Striated Heron";
Label1.Text += "<br />birds array [after update one element from each array]....<br />";
foreach (string s in birds)
{
Label1.Text += s + "<br />";
}
Label1.Text += "<br />cloned birds array [after update one element from each array]...<br />";
foreach (string s in clonedbirds)
{
Label1.Text += s + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - array clone</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
c# example - array clone
</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="clone array"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>

- How to initialize a double array
- How to convert a decimal array to a string
- How to convert a decimal array to a string array
- How to concat two arrays
- How to create an array with non-default value
- How to delete 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
- How to remove the last element from an array
- How to get a subset of an array