Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
根据此处的 MSDN 文档,可以将 Enum 的每个成员强制转换为Int以获取相应的 0 索引值。但我想将一个Int从 0 到 6 的值转换为这个枚举。
Int
这怎么可能?
You can cast it in reverse:
int intValue = 1; DayOfWeek dayOfWeek = (DayOfWeek)intValue;