My application reads an Excel file using VSTO and adds the read data to a StringDictionary
. It adds only data that are numbers with a few digits (1000 1000,2 10
The .NET Framework design guidelines recommend using the Try methods. Avoiding exceptions is usually a good idea.
Convert.ToDouble(object)
will do ((IConvertible) object).ToDouble(null);
Which will call Convert.ToDouble(string, null)
So it's faster to call the string version.
However, the string version just does this:
if (value == null)
{
return 0.0;
}
return double.Parse(value, NumberStyles.Float | NumberStyles.AllowThousands, provider);
So it's faster to do the double.Parse
directly.