Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,890 questions

51,817 answers

573 users

How to enumeration (enum) and switch case in C#

1 Answer

0 votes
using System;

public enum Colors {
	RED, GREEN, BLUE, YELLOW, ORANGE
}
 
class Program
{
    static void Main() {
        Colors c = Colors.GREEN;
        
        switch (c) {
            case Colors.RED:
                Console.WriteLine("red");
                break;
            case Colors.GREEN:
                Console.WriteLine("green");
                break;
            case Colors.BLUE:
                Console.WriteLine("blue");
                break;
            case Colors.YELLOW:
                Console.WriteLine("yellow");
                break;
            case Colors.ORANGE:
                Console.WriteLine("orange");
                break;
            default:
                Console.WriteLine("default");
                break;
        }
    }
}
 
 
 
/*
run:
 
green
 
*/

 



answered Sep 5, 2019 by avibootz

Related questions

1 answer 203 views
1 answer 152 views
152 views asked Nov 9, 2021 by avibootz
2 answers 190 views
1 answer 196 views
196 views asked Aug 7, 2018 by avibootz
1 answer 179 views
1 answer 126 views
126 views asked Apr 25, 2017 by avibootz
1 answer 179 views
...