I have a worker method with an optional parameter
Work(string input = DefaultInput)
{
//do stuff
}
And I have a wrapper around this, which also take the string input, but this can also be optional…
WorkWrapper(int someParameter, string input = DefaultInput)
{
//do initialization
Work(input);
}
The problem here is I duplicate reference to DefaultInput, if, say, I change the default input of work to NewDefaultInput, I will need to update the workWrapper as well, otherwise it will still use the old default.
Is there a way so that the default input do not need to be declared twice? Possibly without having two overloads for workwrapper..
If you want the defaults to be in sync between the two methods, you really don’t need the default in the wrapper, right?
…
If they are in the same class/hierarchy, you could also just declare a
constto ensure that the defaults remain the same.