Check that integer type belongs to enum member
Posted
by Alexander Stalt
on Stack Overflow
See other posts from Stack Overflow
or by Alexander Stalt
Published on 2010-04-09T06:06:43Z
Indexed on
2010/04/09
6:13 UTC
Read the original article
Hit count: 316
c#
Hi!
I want to check that some integer type belongs to (an) enumeration member.
For Example,
public enum Enum1
{
member1 = 4,
member2 = 5,
member3 = 9,
member4 = 0
}
Enum1 e1 = (Enum1)4 gives me member1
Enum1 e2 = (Enum1)10 gives me nothing and I want to check it.
© Stack Overflow or respective owner