Try passing the second argument as type Func<Boolean> . The code should work as it is in the second part of your question:
public void Text(Action action, Func<Boolean> condition) { if (condition()) action(); }
EDIT: Note that what you would do in your use case creates a Closure containing the captured variable variable and variable2. You must understand the consequences of closure before using them this way.
source share