Created
June 3, 2024 12:50
-
-
Save karenpayneoregon/19006aae9ebb34ede08ed0415dab8192 to your computer and use it in GitHub Desktop.
Get season Northern hemisphere
This file contains 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 static class CommonHelpers | |
{ | |
public static string GetSeason(int month) => $"The season is {month switch | |
{ | |
1 or 2 or 12 => "winter", | |
> 2 and < 6 => "spring", | |
> 5 and < 9 => "summer", | |
> 8 and < 12 => "autumn", | |
_ => "unknown.", | |
}}."; | |
public static string CurrentSeason => GetSeason(DateTime.Now.Month); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment