Are C# enums typesafe?
If not what are the implications?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To give a slightly different answer… while the values are type-safe from the casting perspective, they are still unchecked once they have been cast – i.e.
For this reason, you should take care to check the values – for example with a
defaultin aswitchthat throws an exception.You can also check the (for non-[Flags]values) via: