Skip to content

Instantly share code, notes, and snippets.

@in-async
Created September 20, 2023 10:02
Show Gist options
  • Save in-async/cd19e7f9c6e7d9ec8db202cc5c4b3b62 to your computer and use it in GitHub Desktop.
Save in-async/cd19e7f9c6e7d9ec8db202cc5c4b3b62 to your computer and use it in GitHub Desktop.
public static class ObjectInvokeExtensions {
public static TResult Invoke<T, TResult>(this T value, Func<T, TResult> func) {
if (func is null) { throw new ArgumentNullException(nameof(func)); }
return func(value);
}
public static void Invoke<T>(this T value, Action<T> action) {
if (action is null) { throw new ArgumentNullException(nameof(action)); }
action(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment