String to float array
string-to-float-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 stringOfFloat = "25.55,62.12,125,99.11,123.321";
Label1.Text = "string of float value..................<br />";
Label1.Text += stringOfFloat;
//split string and create a float array.
float[] fArray = Array.ConvertAll(stringOfFloat.Split(','), float.Parse);
Label1.Text += "<br /><br /> elements of float array.....";
foreach (float d in fArray)
{
//elements of float array
Label1.Text += "<br />" + d;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to float array</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to float 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 float array"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- How to convert a string to a bool
- How to convert a string to stream
- How to format a string as currency
- How to get color from string
- How to create a csv from a string
- How to convert a string to decimal
- How to write a string to a file
- How to convert a string to a guid
- How to convert a string to a generic list
- How to split a string to key value pairs