Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use the same enum in 2 different classes in C#?

Tags:

c#

enums

uml

I have two classes: Machine and Production. I want to have an enum MachineType to use that in both classes.

If the Production's MachineType does not correspond to the one in the Machine class then the Production cannot be completed.

My question is is it okay to connect one enum to both classes?
Or do i have to create different enums?
And how to display this on UML?

like image 752
Eda Avatar asked Dec 06 '25 10:12

Eda


1 Answers

Yes, you can do that without problem. You denote it by drawing a dependency (dashed line, open arrow) towards the enum from any class which uses it. The enum itself appears in the attributes as typed with the enum.

enter image description here

like image 180
qwerty_so Avatar answered Dec 08 '25 23:12

qwerty_so



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!