Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Created June 13, 2017 10:11
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 PradeepLoganathan/0868ee2617fbcbd7cf35cbb5d9843c1e to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/0868ee2617fbcbd7cf35cbb5d9843c1e to your computer and use it in GitHub Desktop.
switch (age)
{
case 50:
ageBlock = "the big five-oh";
break;
case var testAge when (new List<int>()
{ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89 }).Contains(testAge):
ageBlock = "octogenarian";
break;
case var testAge when ((testAge >= 90) & (testAge <= 99)):
ageBlock = "nonagenarian";
break;
case var testAge when (testAge >= 100):
ageBlock = "centenarian";
break;
default:
ageBlock = "just old";
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment