Can not cast integer to Enum in Generic method

This question already has an answer here:

  • Cast Int to Generic Enum in C# 4 answers

  • As a workaround, instead of (T)x.ToInteger() you should be able to do: (T)(object)x.ToInteger() .

    This involves boxing and unboxing the value but that most likely is not a significant performance issue here.

    链接地址: http://www.djcxy.com/p/54426.html

    上一篇: 枚举标志属性C#

    下一篇: 无法将整数转换为通用方法中的枚举