ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

ToDouble

Converts a string to a double

Source

public static double ToDouble(this string theValue)
{
    double retNum;
    var result = double.TryParse(theValue, out retNum);
    return result ? retNum : 0;
}

Example

string s = "2.2365";

double d = s.ToDouble(); // 2.2365

Author: K M Thomas

Submitted on: 25 mrt 2016

Language: C#

Type: System.String

Views: 4134