问题描述
我使用C#8可为空的引用类型。
我有一个通用类,可以接受可为空的引用类型作为类型参数。
是否有一种方法可以基于可能是可为空的引用类型(甚至是可为空的结构)的泛型类型参数声明不可为空的类型?
abstract class Selector<T>
{
T SelectedItem;
// how to make item parameter not nullable?
abstract string Format(T! item);
// how to make item parameter not nullable?
Func<T!,string> FormatFunction;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)