user2668984
user2668984

Reputation: 11

What are the benefits of using enum-flags?

I wonder what the benefits of using Enum-flags instead of boolean fields (besides a better performance and cleaner code)...

Upvotes: 1

Views: 548

Answers (2)

HerpDerpington
HerpDerpington

Reputation: 4445

I think it's good that if you use flags you won't need many boolean parameters on a method if you have to pass many values. The flags make it easier to overload the method, too.

Upvotes: 0

Ehsan
Ehsan

Reputation: 32681

Flags enumerations are used for masking bit fields and doing bitwise comparisons. They are the correct design to use when multiple enumeration values can be specified at the same time.

As metioned above it is nothing more than correct design, but i guess this is what matters the most.

Upvotes: 1

Related Questions