Skip to content

Instantly share code, notes, and snippets.

@cbrevik
Created June 29, 2020 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbrevik/983fdbdb962c415302e13a3a472ffd3d to your computer and use it in GitHub Desktop.
Save cbrevik/983fdbdb962c415302e13a3a472ffd3d to your computer and use it in GitHub Desktop.
int birthYear = (ruleNumber, year) switch
{
// Rule 1. 500–749: 1854–1899
(>= 500 and <= 749, >= 54) => 1800 + year,
// Rule 2. 000–499: 1900–1999
(< 500, _) => 1900 + year,
// Rule 3. 900–999: 1940–1999
(>= 900, >= 40) => 1900 + year,
// Rule 4. 500–999: 2000–2039
(>= 500, <= 39) => 2000 + year,
// No rule
(_, _) => 0
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment