Try Again YesNo Next Exercise » What is an enum in C#? A variable that can store multiple values. A special 'class' that represents a group of constants. A method that returns multiple values. A data type that allows runtime changes. ...
Sign In Get Certified For Teachers Spaces Plus ❮ ❯ HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY ...
Inside the main() method, specify the enum keyword, followed by the name of the enum (Level) and then the name of the enum variable (myVar in this example):enum Level myVar; Now that you have created an enum variable (myVar), you can assign a value to it....
Enums are often used inswitchstatements to check for corresponding values: Example enumLevel{Low,Medium,High}staticvoidMain(string[]args){LevelmyVar=Level.Medium;switch(myVar){caseLevel.Low:Console.WriteLine("Low level");break;caseLevel.Medium:Console.WriteLine("Medium level");break;caseLevel.High...
× Sign in Submit Answer »