Can I set one enum value equal to another enum value?

I’m working on a football simulation game and I need to assign the players different attributes. For Example: Justin Miller, 85 speed, 85 strength, etc. Is there any way that i can make an enum for the names and one for the attributes, and set them equal to each other?

Any help is greatly appreciated!

p.s. The scripts are in c#.

I´m not very sure what you mean but I´ll try to answer your question.

You can set an enum value equal to another enum value, casting it twice (or at least that´s how I would do it. For example:

enum Enum1{
    hi,
    bye
}

enum Enum2{
    foot,
    hand
}

Enum1 enum1;
Enum2 enum2;

void CastEnum2ToEnum1(){
    enum1 = (Enum2) ((int) enum2);
}

However that seems a terrible idea and that is not how enums should be used. Diferent enums should not assign each other because they handle information that is independent and uncomparable conceptually.

Yes you can.

Enums are nothing but a struct with constants; you assign arbitrary values as you wish, with the understanding that

  • you can only use int values
  • you are forced by logic to assume that 2 enum entry, with the same value, are in fact the same entry

public enum myEnum
{
wine = 10,
water = 2,
wateredwine = 3,
wateredliquor = 3,
liquor = 10
}

In this statement, you are assuming that wine and liquor are the same, because they have the same value; same for watered wine and watered liquor.

If this is illogic, depends from how do you use the enum in which context. If you use it to set values for a multiplier for example, in a pinball game; it makes totally sense that you have different entry with the same enum value:

public enum myEnum
{
    bridge1 = 10,
    bumper1 = 2,
    ramp1 = 3,
    ramp2 = 3,
    bridge2= 10
}

In this case you know that bridge1 and bridge2 are different entry, but you use them for their multiplier; same for ramp1 and ramp2.