Reputation: 199
How can I convert a number held by a string into a double?
Upvotes: 0
Views: 249
Reputation: 6085
The "safe" way:
string number = "9";
double result;
if(!double.TryParse(number, out result))
{
// conversion failed, string is not a valid double/number
}
or the "optimistic" way:
Convert.ToDouble(number);
Upvotes: 5