String to double array
string-to-double-array.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
//this section create a string variable.
string stringOfDoubles = "125.55,23.99,12.01,85.25,99.999";
Label1.Text = "string of double value..................<br />";
Label1.Text += stringOfDoubles;
//this line split string and create a double array.
double[] dArray = Array.ConvertAll(stringOfDoubles.Split(','),Double.Parse);
Label1.Text += "<br /><br /> elements of double array.....";
foreach (double d in dArray)
{
//elements of double array
Label1.Text += "<br />" + d;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to double array</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to double array
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="string to double array"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- String split and join
- How to format a string as a phone number
- How to format a string as a number with leading zero
- How to format a string as a date without time
- How to format a string as decimal
- How to check whether a string contains a specific character
- How to check whether a string contains at least one number
- How to create a csv from a string
- How to convert a string to decimal
- How to convert a delimited string to a dictionary