You have introduced a Globalization / Regional problem by requiring the default value to be a
double? value = InputBox.GetDouble("xyz", "1.0");
double? value2 = InputBox.GetDouble("xyz", "1,0");
One of these two will fail, but not on every machine or country or even on the the same line. The '
Parse()', and '
string.Format()' methods are running under the regional settings of the thread. Which is by default the same as the
RegionalSettings for the logged on user, but it does not have to be. For more information, read the helpfile for these functions.
We can elevate the pain for the default value by making the default value the same type as the result; this helps greatly, unless
string is the native value for the default, in which case you might need two versions of the method.
public static double? GetDouble(string caption, double?defaultValue)
using (InputForm inForm = new InputForm(caption, defaultValue.ToString()))
[edit: and the rest]