I was looking at the summary of the StringSplitOptions enum and and then was surprised to see it has the Flags attribute applied to it.
The Flags enum is relevant for things like BindingFlags
where you'd like to do things like BindingFlags.Public | BindingFlags.NonPublic
but in StringSplitOptions
's case using StringSplitOptions.None | StringSplitOptions.RemoveEmptyEntries
doesn't look correct.
So what are the reasons to use the Flags
attribute on a Enum like StringSplitOptions
that has only two different values one of them being "no value" (None) ?
StringSplitOptions
is conceptually a flags enum, even if it only has one flag right now.
In the future, they might add more options to StringSplitOptions
. These new options would be added as flags, and you would be able to combine them with RemoveEmptyEntries
.
So, it makes sense to pre-emptively mark StringSplitOptions
with [Flags]
.