是的,C#中的switch语句支持枚举类型。枚举类型在C#中被视为一种整数类型,因此可以在switch语句中使用。示例如下:
enum Color
{
Red,
Blue,
Green
}
Color color = Color.Red;
switch (color)
{
case Color.Red:
Console.WriteLine("The color is red");
break;
case Color.Blue:
Console.WriteLine("The color is blue");
break;
case Color.Green:
Console.WriteLine("The color is green");
break;
default:
Console.WriteLine("Unknown color");
break;
}