Simple, use the binary "or" operator:
BiomeType bType = BiomeType.Hot | BiomeType.Dry;
Also, if the values can be combined like this it's best to mark the enum with the Flags
attribute to indicate this:
[Flags]
public enum BiomeType {
Warm = 1,
Hot = 2,
Cold = 4,
Intermediate = 8,
Dry = 16,
Moist = 32,
Wet = 64,
}
Adding enumeration values is bad for a number of reasons. It makes it easy to produce a value that is outside the defined values, i.e.:
BiomeType bType = (BiomeType)((byte)BiomeType.Wet + (byte)BiomeType.Wet);
While contrived, this example yields a value of 128, which doesn't map to a known value. This will still compile and run, but it's likely you didn't build your code to handle values outside of those defined and could lead to undefined behavior. However, if you use the pipe (or "binary or") operator:
BiomeType bType = BiomeType.Wet | BiomeType.Wet;
The result is still just BiomeType.Wet
.
Furthermore, using addition like in your question provides no Intellisense in the IDE which makes using the enumeration unnecessarily more difficult.