Reputation: 43
I'm trying to add classes to an enum
, but I can't find a way to make it work.
I have a "main" class (let's call it Product
) which should hold some other different classes, that hold different properties, under a single enum
(let's call it Property
). The Property
enum
should contain multiple different classes which fall under the Product
class, so that I can use one of them, depending on which product is in question. However, when I try to include a class under an enum
, it's not being recognized as a class at all.
Is there way to include classes as members under an enum
?
Upvotes: 0
Views: 118
Reputation: 1322
There is not.
See enum-Reference:
Every enumeration type has an underlying type, which can be any integral numeric type.
An enum type is always numeric.
Upvotes: 1
Reputation: 7845
No, this not what enums are build for.
Enums are like primitve classes (like int
) and should be used in this way.
Upvotes: 0