【发布时间】:2019-11-25 06:34:46
【问题描述】:
我有一个 C# 代码片段,错误如下:
无法将 System.ValueType 转换为 T
请指导我解决这个问题
这是一个代码
public static T Add<T>(this Enum type, T value)
{
try
{
return (T) (ValueType) (Convert.ToInt32(type) | (int) (object) value);
}
catch (Exception ex)
{
throw new ArgumentException(string.Format("Could not append value from enumerated type '{0}'.", (object) typeof (T).Name), ex);
}
}
现在我该如何运行这个错误?
【问题讨论】:
-
@Jazb 不幸的是没有。 thic 代码在 32 位版本中真正运行。当我们反编译它并以64位重新编译时,出现了这个错误
-
从一开始就分享它会很有用......
标签: c# asp.net enums typeconverter generic-type-argument