Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.