Language Basics C# Book

Enum has a static method we can use to check if an enum value is defined.
using System;
public enum WeekDay{
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}
class Test
{
static void Main()
{
WeekDay day = (WeekDay)111;
if (Enum.IsDefined(day.GetType(),day))
{
Console.WriteLine("defined");
}
else
{
Console.WriteLine("not defined");
}
}
}
The output:
not defined