Hier ein kurzes Beispiel für eine einfach c# switch case Variante
using System; public enum Color { Red, Green, Blue } public class Example { public static void Main() { Color c = (Color) (new Random()).Next(0, 3); switch (c) { case Color.Red: Console.WriteLine("The color is red"); break; case Color.Green: Console.WriteLine("The color is green"); break; case Color.Blue: Console.WriteLine("The color is blue"); break; default: Console.WriteLine("The color is unknown."); break; } } }
Über den Autor