Convert string array to list
convert-string-array-to-list.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
string[] birds = new string[] { "Snail Kite", "Black Kite", "Red Kite", "Pied Harrier" };
List<string> birdslist = birds.OfType<string>().ToList();
Label1.Text = "birds array: ";
foreach(string s in birds)
{
Label1.Text += s + " | ";
}
Label1.Text += "<br /><br />birds list: ";
foreach (string s in birdslist)
{
Label1.Text += s + " | ";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - convert string array to list</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
c# example - convert string array to list
</h2>
<hr width="550" align="left" color="LightBlue" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="convert string array to list"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- How to initialize a string array
- How to initialize a two dimensional string array
- How to convert a string to a byte array
- How to convert a string array to a double array
- How to convert a string array to an int array
- How to convert a decimal array to a double array
- How to convert a string array to a string
- How to convert a string array to a comma separated string
- How to convert a string array to a csv
- How to perform binary search on an array