public static T Process<T>(Func<T> getresponse) where T : Parent, new()
try { return getresponse(); }
catch { return new T() { I = 5 }; }
public static void Main()
var x = Process(() => new Child(9));
Console.WriteLine(x.I.ToString());
var y = Process(() => new Child(0));
Console.WriteLine(y?.I.ToString() ?? "null");
public Parent(int i) { I = i; }
public int I { get; set; }
public class Child : Parent
public Child(int j) : base(j) { if (j == 0) throw new ArgumentException("Helolo world"); }