Hello,
In my project I have a few functions in derived classes that are the same except for one section that is different in each.
I want to pull the method up to the base class.
The functions look like this:
func(parameters)
{
//COMMON BITS
if (someVar == "value1") { htmlFilename = line; }
else if (someVar == "value2") { subVideoLink = line; }
else if (someVar == "value3") { linksH2HeadingWritten = true; }
//COMMON BITS
}
where the center lines of the different functions all look like above but have different values for "someVar" and different variables in the "variable = line;" format.
This is the generalized form:
if (someVar == "CommandName") { variable = line; }
The idea I had was to send the function a Dictionary<string CommandName, ref string>
... however it seems I can't make a Dictionary with ref string in it...
I would then remove the boolean cases of the 'variable' by replacing them with string versions with values of "true" or "false".
Is there a better way to do this?