Refactoring complex nested if-else trees into clean, declarative C# switch expressions:
public static decimal CalculateDiscount(Customer customer, Order order) => (customer, order) switch
{
{ customer.IsVip: true, order.Total: > 1000m } => 0.25m, // 25% VIP bulk discount
{ customer.IsVip: true } => 0.15m, // 15% VIP standard
{ order.Total: > 500m } => 0.10m, // 10% standard bulk
{ customer.RegisteredYears: >= 5 } => 0.05m, // Loyalty
_ => 0.00m // Default fallback
};The compiler verifies pattern exhaustiveness and optimizes evaluations into jump tables and bit tests!