Tech
How I replaced if statements with a Dictionary delegate in C#
Let's say you need to implement a feature that returns a different package based on the user-provided coupon code.
So you start with a model:
public record Package
{
public int Id { get ; set ; }
public string Name { get ; set ; }
public double Price { get ; set ; }
}
And you write a function that returns a different package based on the coupon code:
private static Package GetPackageFromCoup...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to