using System; using System.Linq; using System.Collections.Generic; using System.Collections.Concurrent; using System.Reflection; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; var method = typeof(Rules).GetMethod(nameof(Rules.Positive))!; try { method.Invoke(null, new object?[] { 0 }); } catch (TargetInvocationException error) { Console.WriteLine($"outer:{error.GetType().Name}"); Console.WriteLine($"inner:{error.InnerException!.GetType().Name}"); } Func direct = Rules.Positive; try { direct(0); } catch (ArgumentOutOfRangeException error) { Console.WriteLine($"delegate:{error.GetType().Name}"); } static class Rules { public static int Positive(int value) => value > 0 ? value : throw new ArgumentOutOfRangeException(nameof(value)); }