❔ How do I cast a byte to an enum MyEnum : byte
As the title says really, I have a
public enum MyEnum : byte
and I want to cast byte?
to the enum. How do I do that? 🤔8 Replies
(MyEnum)someByte
Windows10CE#8553
REPL Result: Success
Console Output
Compile: 578.446ms | Execution: 76.761ms | React with ❌ to remove this embed.
oh you have a byte?
what do you want to happen when it's null
a null reference exception? some default value?
null reference exception
(MyEnum)(object)nullableByte
or (MyEnum)nullableByte.Value if you're okay with InvalidOperationException instead
Thank you ❤️
(MyEnum?) nullableByte
To cast it to a nullable version of your enumWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.