February 2019
Intermediate to advanced
626 pages
15h 51m
English
By default, an enumeration matches a single value. If the enumeration contains more than one name for a value, the first name will be chosen.
The flags attribute allows a value to describe more than one name. The flags attribute is placed before the enum keyword.
Typically, each value in the enumeration is given a value with a unique bit combination. This is shown in the following enumeration; the bit combination is shown in the comment after the value:
[Flags()]enum MyEnum { First = 1 # 001 Second = 2 # 010 Third = 4 # 100}
Automatic value assignment cannot be reasonably used to assign values for a flags enumeration at the time of writing.
When the flags attribute is present, PowerShell will cast a string that contains ...
Read now
Unlock full access