可能重复: 在C#中将int转换为枚举
如果我有以下代码:
enum foo : int { option1 = 1, option2, ... } private foo convertIntToFoo(int value) { // Convert int to respective Foo value or throw exception }
转换代码会是什么样的?
c# enums
c# ×1
enums ×1