Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Last active February 20, 2017 07:44
Show Gist options
  • Save masaru-b-cl/23de0768d9087eb08def83e996989964 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/23de0768d9087eb08def83e996989964 to your computer and use it in GitHub Desktop.
値の範囲で型スイッチによる分岐 in C#
int a = ...;
switch (a)
{
case int _ when a < 10: return "low";
case int _ when 90 < a: return "high";
default: return "middle";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment