In C# I have the following function definition:
public static TResult SomeParentFunctionName<TSource, TResult>(
TSource SomeValue,
Func<TSource, TResult> ChildFunction1,
Func<TSource, TResult> ChildFunction2)
This function takes SomeValue and then calls ChildFunction1 and ChildFunction2
According to my business rules, I always need to run ChildFunction1, but only sometimes need to run ChildFunction2.
Can I make ChildFunction2 an optional parameter? How do I go about doing that? And how do I know if it has been passed in.
Options I have considered:
I could create two
SomeParentFunctionNamefunctions, one withChildFunction2and one without.I could pass in a blank function that just won't do anything - but that's not good practice.