In my query string, I have an age variable ?age=New_Born
.
Is there a way I can check if this string value New_Born
is in my Enum list
[Flags]
public enum Age
{
New_Born = 1,
Toddler = 2,
Preschool = 4,
Kindergarten = 8
}
I could use if statement for right now, but if my Enum list gets bigger. I want to find a better way to do it. I am thinking about to use Linq, just not sure how to do it.
You can use:
Enum.IsDefined(typeof(Age), youragevariable)