© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
7 replies
Hugh

✅ Calling a nullable Action or Func

In my class I have the following:

private Action<bool>? _myAction;
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);
_myAction?(true);


Similarly with a Func, can I do something like:

private Func<bool, bool>? _myFunc;

bool result = _myFunc?(true) ?? false;
private Func<bool, bool>? _myFunc;

bool result = _myFunc?(true) ?? false;
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Exporting Func/Action?
C#CC# / help
3y ago
✅ calling functions
C#CC# / help
3y ago
❔ Nullable enums or None inside
C#CC# / help
4y ago
Calling a function from a string.
C#CC# / help
4y ago