C#C
C#3y ago
Hugh

✅ Calling a nullable Action or Func

In my class I have the following:

private Action<bool>? _myAction;

Is there a way of calling it if it isn't null in a single line? Something like (and this doesn't work):

_myAction?(true);


Similarly with a Func, can I do something like:

private Func<bool, bool>? _myFunc;

bool result = _myFunc?(true) ?? false;
Was this page helpful?