I have a business class that contains two nullable decimal properties. A third property returns the result of multiplying the other two properties. If HasValue is true for the two nullable types then I multiply and return the result. I have a few options for the return value if one or both of the properties is null:
- Return 0
- Throw an exception
- Return a magic number (-1)
- Return decimal? (EDIT -- see comments)
I thought one of my options would be to return NaN, but I see that this is only possible for the double type. Why is this?
For the record, returning 0 makes the most sense in this case and that's what I plan to do unless someone has a better suggestion.