Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,在为客户设计一个类时,为 CustomerType 使用 Enum 是否有意义?
这取决于其他约束。你没有告诉我们足够的关于你的模型。例如,如果不同类型的客户具有与其相关联的不同类型的信息,则类层次结构将比单纯的枚举更适合。
在其他情况下,枚举会很好,甚至可能是首选(更简单,减少开销......)。