Created
July 29, 2018 07:15
-
-
Save AmirOfir/1a5482a5ebd184644e0b4c2131743a2b to your computer and use it in GitHub Desktop.
DateRange with nullable optional parameters - c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public DateTime? From { get; set; } | |
public DateTime? To { get; set; } | |
readonly DateTime minFrom = new DateTime(2000, 1, 1); | |
readonly DateTime maxTo = new DateTime(2100, 1, 1); | |
public DateTime SafeFrom() => | |
From.GetValueOrDefault(To.GetValueOrDefault(minFrom)); | |
public DateTime SafeTo() => | |
To.GetValueOrDefault(From.GetValueOrDefault(maxTo)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment