Код: Выделить всё
// TSource1 elementObj can be struct or can be class object and never can be nullable struct or null (because method inner code will create Exceptions in that case)
public static TSource1? ReturnNullOrNotNullTSource1(TSource1 elementObj)
{
// making some checkings for elementObj, if chekings have passed I need to return that elementObj back, if chekings have not passed I need to return null (so I used TSource1? as a method return type).
// ...
return (passed) ? elementObj : default(TSource1?);
}
Код: Выделить всё
var result = ReturnNullOrNotNullTSource1(new DateOnly(0001, 1, 1));
Подробнее здесь: https://stackoverflow.com/questions/791 ... t-that-can