Wrong!
This code compiles and executes with no runtime error:
using System;
namespace Enumerating_Fun {
enum EnumLegalColor{red=1, white=2, blue=3};
class Program {
static void Main(string[] args) {
PrintColor(EnumLegalColor.red);
PrintColor(EnumLegalColor.white);
PrintColor(EnumLegalColor.blue);
PrintColor((EnumLegalColor) 1234);
while(!Console.KeyAvailable)
;
}
static void PrintColor(EnumLegalColor color) {
switch(color) {
case EnumLegalColor.red:
Console.WriteLine("Le Rouge");
break;
case EnumLegalColor.white:
Console.WriteLine("Le Blank");
break;
case EnumLegalColor.blue:
Console.WriteLine("Le Blu");
break;
default:
Console.WriteLine("WTF!");
break;
}
}
}
}
No comments:
Post a Comment