You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But FavouriteAncientWonder is designed to hold only one value, whereas with System.Flags it can contain multiple values like BucketList.
I realize this is just a synthetic example, but anyway IMHO each hmm... entity should only be allowed to serve its original purpose to avoid possible bugs and unexpected behaviour.
The text was updated successfully, but these errors were encountered:
I see what you mean. There is nothing to prevent someone from setting the FavoriteAncientWonder to a value that represents multiple wonders. It would be interesting to know how .NET APIs handle this. There are plenty of flags-type enums defined and there must be some scenarios where they must be used singularly. Or maybe not? I suppose if FavoriteAncientWonder was defined as a property then its setter could do some validation. I will do some research. Thanks for raising this interesting issue. :)
After applying
[System.Flags]
toWondersOfTheAncientWorld
enum, the class contains two fields of the same type:But
FavouriteAncientWonder
is designed to hold only one value, whereas withSystem.Flags
it can contain multiple values likeBucketList
.I realize this is just a synthetic example, but anyway IMHO each hmm... entity should only be allowed to serve its original purpose to avoid possible bugs and unexpected behaviour.
The text was updated successfully, but these errors were encountered: