public class Demo
{
public void When(Func<Person, bool> condition)
{
if (!condition)
{
Log.Info("Condition not met.");
return;
}
// Do something
}
}
In the When
method, I would like to log when a predicate or Func<bool>
returns false. However, just logging "condition not met" doesn't give me much information. If I call the method like so:
demo.When(x => x.Name == "John");
Is there a way to convert that expression into a readable/meaningful string for logging purposes?