What's the proper way of dealing with nullable types like 'DateTime?'? When you need to pick a smaller of 2 dates that are nullable and one of them is null, < or > won't do as comparing null to actual date results in false, so for example:
DateTime? function( DateTime? a, DateTime? b ){
return a < b ? a : b;
}
would return b if either a or b were null.
Do I have to use if-statements or is there a workaround?
Edit: I'd like not-null to be returned if one of the values is null
Edit: I'm sorry if it was confusing that I used a function as an example. It's not that I wanted to avoid using if-statements. But there's a lot of comparisms between nullable DateTimes and I'd like to avoid creating custom comparators that would require an explicti call and such.
Is it possible to override the default DateTime? comparators?