Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@richlander
Created January 29, 2019 17:01
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 richlander/ddd9bfbcc26256376ed8bb1e2a9929b2 to your computer and use it in GitHub Desktop.
Save richlander/ddd9bfbcc26256376ed8bb1e2a9929b2 to your computer and use it in GitHub Desktop.
C# 8 Switch Expression
static string Display(object o) => o switch
{
Point { X: 0, Y: 0 } => "origin",
Point { X: var x, Y: var y } => $"({x}, {y})",
_ => "unknown"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment