What is ENUM and what are the benefits of using it (ENUM C# Interview Question 1)?
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.
So summarizing ENUM has two big benefits:-
- Code becomes more readable.
- Easy to change constants without affecting throughout the project. Easy maintenance.
Next ENUM C# Interview questions: -What are flags in Enum ?
This question is taken from the book .NET Interview questions with answers
This is a nice .NET Interview question video which talks about Build Vs Rebuild solution.
Watch our latest video on C# interview questions & answers :-