Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save ufcpp/896d67cc0841db74c422 to your computer and use it in GitHub Desktop.

Select an option

Save ufcpp/896d67cc0841db74c422 to your computer and use it in GitHub Desktop.
type pattern matching
public static void ShowBattleAction(BattleAction action)
{
var heal = action as Heal;
if (heal != null) ShowHeal(heal);
var attack = action as Attack;
if (attack != null) ShowAttack(attack);
}
public static void ShowBattleAction(BattleAction action)
{
if (action is Heal heal) ShowHeal(heal);
else if (action is Attack attack) ShowAttack(attack);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment