I'm trying to convert a string to a double. If it encounters null value the value should then be 0 (zero). However, it comes up with an error message:
"Operator '??' cannot be applied to operands of type 'double' and 'double'. It's sort of confusing because both numbers are double? How do I fix this?
double final = double.Parse(min.ToString()) ?? 0.0;
Maybe this, assuming
min is a
double final = double.Parse(min ?? "0");
double final = (min == null) ? 0 : double.Parse(min);
double final = Convert.ToDouble(min);
Per the documentation, that method will return
A double-precision floating-point number that is equivalent to the number in value, or 0 (zero) if value is null.