Some fun with enums! Assume you have an enum defined as follows:
enum Frequency {
None = 0,
Annual = 1,
SemiAnnual = 2,
Quarterly = 4,
Monthly = 12,
Weekly = 52
}
Now, given the following block of code:
Frequency myFrequency = (Frequency) 104;
System.Console.WriteLine("My frequency is: {0}", myFrequency.ToString());
bool is100Defined = Enum.IsDefined(typeof(Frequency), 100);
bool is52Defined = Enum.IsDefined(typeof(Frequency), 52);
- What is written to the console?
- What is the value of is100Defined?
- What is the value of is52Defined?
First correct answer gets absolutely nothing (but think how great you’ll feel!)
