I need to validate an integer to know if is a valid enum value.
What is the best way to do this in C#?
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.
You got to love these folk who assume that data not only always comes from a UI, but a UI within your control!
IsDefinedis fine for most scenarios, you could start with:(Obviously just drop the ‘this’ if you don’t think it’s a suitable int extension)