AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

StringExtensions..::..ToDouble Method

Parses the string as a double, returning the specified default value if parsing fails.

Namespace:  AdvantageCMS.Core.Common
Assembly:  AdvantageCMS.Core (in AdvantageCMS.Core.dll)

Syntax


public static double ToDouble(
	this string s,
	double defaultValue
)

Parameters

s
Type: String
The string to parse.
defaultValue
Type: Double
The value to return if parsing fails.

Return Value

The parsed double value, or defaultValue if parsing fails.

Examples


C#
string price = "19.99";
double result = price.ToDouble(0.0); // returns 19.99
double fallback = "N/A".ToDouble(0.0); // returns 0.0