Created
September 6, 2017 16:04
-
-
Save Blind-Striker/8311d56d0326d976ec6cdc74462db4fe to your computer and use it in GitHub Desktop.
C# 7.0 Pattern Matching example for blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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