Login
C# - сделать в потомке дженерика параметр типа налловым
94 просмотров
Перейти к просмотру всей ветки
in Antwort alex445 2 Tage zurück, 22:54
class Base<T>
{
protected T CoreProcess(T input)
{
// общий код
}
public T ProcessValue(T input) => CoreProcess(input);
}
----
class Derived<T> : Base<T>
where T : struct, INumber<T>
{
public T? ProcessValue(T? input)
{
if (input is null)
return null;
return CoreProcess(input.Value);
}
}
Zurück