Convert string array to int array
convert-string-array-to-int-array.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
string[] stringarray = new string[]
{
"100",
"99",
"125",
"122",
"25"
};
Label1.Text = "string array.........<br />";
foreach (string s in stringarray)
{
Label1.Text += s + "<br />";
}
int[] intarray = new int[stringarray.Length];
for (int i = 0; i < stringarray.Length;i++ )
{
intarray[i] = Convert.ToInt32(stringarray[i]);
}
Label1.Text += "<br />int array.........<br />";
foreach (double d in intarray)
{
Label1.Text += d.ToString() + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - convert string array to int array</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
c# example - convert string array to int array
</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 int array"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- How to initialize a double array
- How to convert a double array to a string
- How to convert a string array to a double array
- How to convert a decimal array to a string
- How to convert a decimal array to a string 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