What are the differences between enum and class ?

public enum Colors{[Description("Red")]Red,[Description("White")]White,[Description("Blue")]Blue,[Description("Green")]Green}
using System;using System.ComponentModel;namespace EnumApp{public enum Colors{  [Description("Red")]   Red,  [Description("White")]   White,   [Description("Blue")]   Blue,   [Description("Green")]   Green}class Program{   static void Main(string[] args)   {     String color = "White";     switch(color)     {       case "Red":        Console.WriteLine("Color is " + Colors.Red);       break;       case "White":        Console.WriteLine("Color is " + Colors.White);       break;       case "Blue":        Console.WriteLine("Color is " + Colors.Blue);       break;       case "Green":        Console.WriteLine("Color is " + Colors.Green);       break;      default:       Console.WriteLine($"{color} is a unknown color by system");      break;  }   Console.ReadLine();  } }}

--

--

--

Computer Engineer, Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What if Women Went on Strike?

I switched to Linux

VulnHub — BlueMoon:2021 Walkthrough

Preparing a Wedding like an Android Developer — Part 1

Taking a timeout — From Go To Rust

MOST IMPORTANT SQL QUERIES TO KNOW

Pointers in C Programming(Concepts)

Micro-Frontends: What, Why (and why not) and How

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Taşkın Binbir

Taşkın Binbir

Computer Engineer, Software Developer

More from Medium

The Facilis framework for dotnet core — the primary key

ASP.NET Core Configuration: adding all configs at one line of code

Using a Custom PageList class for Generic Pagination in .NET Core

How to make a fast application cache with specific conditions for huge Web API calls on .NET