You could also consider dropping enum
and switch
entirely, and use an Enumeration class
instead.
This way you code will end up as:
public CardType : Enumeration
{
public CardType( int id, string name, bool chooseCard )
: base(id,name)
{
ChooseCard = chooseCard;
}
public static readonly Unknown = new CardType(-1,"unknown", false);
public static readonly F1 = new CardType(1,"F1", true);
public static readonly F2 = new CardType(2,"F2", true);
public static readonly F3 = new CardType(3,"F3", true);
public static readonly F4 = new CardType(4,"F4", true);
public static readonly F5 = new CardType(5,"F5", true);
public static readonly H = new CardType(10,"H", false);
public bool ChooseCard { get; }
public bool ChooseHide => ChooseCard == false;
public bool IsUnknown => Id == Unknown.Id;
}
TestChoice( CardType cardChoice ) {
if( cardChoice.IsUnknown )
throw new InvalidEnumArgumentException("Unhandled value: " + cardChoice.ToString());
if( cardChoice.ChooseCard )
return $"There are 0 cards in this collection.Add cards by tapping > of any card set then choose {cardChoice}.";
if( cardChoice.ChooseHide )
return "There are 0 cards in this collection. Add cards by tapping > of any card set then choose Hide.";
...
}
example written with free hands, no compiling
You can specialized each card by its own type, if more properties are added.
It requires a little more coding when declaring the "enum", but simplifies where ever it is used - makes the code more readable and understandable.
Read more here: https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types