Skip to content

Instantly share code, notes, and snippets.

@Blind-Striker
Created September 6, 2017 16:04
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 Blind-Striker/8311d56d0326d976ec6cdc74462db4fe to your computer and use it in GitHub Desktop.
Save Blind-Striker/8311d56d0326d976ec6cdc74462db4fe to your computer and use it in GitHub Desktop.
C# 7.0 Pattern Matching example for blog
public static void ShowUserBalance(object balance)
{
if (balance is null) // constant pattern "null"
{
return;
}
if (balance is decimal userBalance) // type pattern "decimal userBalance"
{
Console.WriteLine($"Kullanıcının bakiyesi {userBalance}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment