【发布时间】:2015-12-20 08:03:48
【问题描述】:
我收到错误:
'' 类型的值不能用作默认参数,因为没有标准转换为 'T' 类型
在尝试编写这段代码时
protected T GetValue<T>(Expression<Func<T>> property, T defaultValueIfNull = null);
有没有人知道如何制作空值类型。有没有办法做到这一点?
【问题讨论】:
-
protected T GetValue<T>(Expression<Func<T>> property, T defaultValueIfNull = null) where T:class
标签: c# generics type-conversion nullable