【发布时间】:2021-09-27 21:35:51
【问题描述】:
为什么下面的代码不起作用?
public T? Method<T>()
{
/*
error CS0403: Cannot convert null to type parameter 'T'
because it could be a non-nullable value type.
Consider using 'default(T)' instead.
*/
return null;
}
【问题讨论】:
-
我将其作为副本关闭并重新打开。这个问题需要在现代 C# 中进一步澄清。
标签: c#