Skip to content

Instantly share code, notes, and snippets.

@avegaraju
Last active September 23, 2018 00:41
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 avegaraju/d53bccf85e229197c021c854b9b52437 to your computer and use it in GitHub Desktop.
Save avegaraju/d53bccf85e229197c021c854b9b52437 to your computer and use it in GitHub Desktop.
public void PaymentMethod(object o)
{
switch (o)
{
case string s when s.Contains("CashOnDelivery"):
Console.WriteLine("cash on delivery");
break;
case Paypal pId when pId.Id != null:
Console.WriteLine($"paypal {pId.Id}");
break;
case Card card when card.IsValidCardNumber():
Console.WriteLine($"Card {card.Number} - {card.Type}");
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment