vendredi 18 mars 2022

Enumeration with subtypes c#

First of all perhaps this is a problem due to a bad design. Here is my scenario simplified:

I have a class call Day it represent a day of the year, with its date and the "type" of day.

public class Day{
 Date Key;
 TypeDay type;
}

So the day can be a worked day or a holiday one:

public enum TypeDay{
    Work,
    Holiday
}

So far so good, but now holiday days can have subtypes like paidDays and NonPaid days I would need another enum to represent that subtypes or add all subtypes in a single enum (in this example i have 2 days and 2 subtypes but in real live i have 50-40 types) so this get so messy .

 public enum TypeDay{
        Work,
        Holiday_NonPaid
        Holiday_Paid
    }

How can i build this in a better way,any ideas?

Aucun commentaire:

Enregistrer un commentaire