ENUM helps to define, manage and assign constants in effective way. Now the below sample code is good but the level values are not readable.
Now by declaring a simple enum called as Quality as shown below.
Our code would look more readable as shown below. The other big benefit is if we change the numeric values of quality we do not have to change throughout the project. So we can go a change the Low quality to 1 and no change in code is required.
Use of Flagsin ENUM: -
“Flags” is an ENUM attribute. If you want to set multiple values to an ENUM we need to use Flags.
In the below code we are setting “MyColors” ENUM to “Blue” and “Green” value.
Also see another .NET interview questions video on difference between IEnumerable and IEnumerator: -