public interface INullableAlgorithm<in TInput, out TOutput>
TOutput? Put(TInput input);
public struct TestStruct {
public class Test : INullableAlgorithm<int, TestClass> {
public TestClass? Put(int input) {
return new TestClass { A = input };
public class Test2 : INullableAlgorithm<int, TestStruct?> {
public TestStruct? Put(int input) {
return new TestStruct { A = input };
public static void Main()
var output = algo.Put(2);
Console.WriteLine(output?.A);
var output2 = algo2.Put(2);
Console.WriteLine(output2?.A);