String to double
.net Convert.ToDouble() method converts a specified value to a double-precision floating-point number. this method have few overload.
Convert.ToDouble(String) overloaded method allow us to convert the specified string representation of a number to its equivalent
double-precision floating-point number. this method is under System namespace.
the Convert.ToDouble(String) method require to pass a parameter named 'value'. this parameter value data type is System.String. this string contains the number to convert. the method return value data type is System.Double. this return value represent a double-precision floating-point number which is equivalent to the number in specified string. its return 0 (zero) if parameter value is null.
the following .net c# example code demonstrate us how can we convert a string object to its equivalent double value in an asp.net application.
the Convert.ToDouble(String) method require to pass a parameter named 'value'. this parameter value data type is System.String. this string contains the number to convert. the method return value data type is System.Double. this return value represent a double-precision floating-point number which is equivalent to the number in specified string. its return 0 (zero) if parameter value is null.
the following .net c# example code demonstrate us how can we convert a string object to its equivalent double value in an asp.net application.
string-to-double.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 doubleValueString = "123.2598";
Label1.Text = "string of double value..................<br />";
Label1.Text += doubleValueString;
//this line convert/parse/transform string to double.
double doubleValue = Convert.ToDouble(doubleValueString);
//convert string value to double with culture.
double doubleValue2 = Convert.ToDouble(doubleValueString,System.Globalization.CultureInfo.InvariantCulture);
Label1.Text += "<br /><br />converted double from string.........<br />";
Label1.Text += doubleValue;
Label1.Text += "<br /><br />converted double from string with culture.........<br />";
Label1.Text += doubleValue2;
Label1.Text += "<br /><br />converted double and add 5 .........<br />";
Label1.Text += doubleValue + 5;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to double</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to double
</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"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>

- How to format a string as datetime yyyyMMdd
- How to convert a string to float
- How to parse a string into char
- How to convert a string to a guid
- How to convert a string to a generic list
- How to get bytes from a string
- How to convert a string to an int list
- How to convert a string to an IP address
- How to convert a string to an int array
- How to split a string to key value pairs