casting int to enum in if statement c# code example Example: convert int to enum c# YourEnum foo = (YourEnum)yourInt;