Hi there, I’m just trying to create a function where I can specify a variable I want to toggle on and off using a parameter and then toggle that variable. I’m using C#.
I keep getting an error saying I can’t convert a ‘string’ to a ‘bool’.
Here’s what I’ve got so far.
public bool variableA = true;
public bool variableB = true;
public bool variableWithADifferentNameC = true;
public void InvertBoolean (string booleanString)
{
if (booleanString)
{
booleanString = false;
} else {
booleanString = true;
}
}
void RandomFunction ()
{
InvertBoolean("variableA");
InvertBoolean("variableB");
InvertBoolean("variableWithADifferentNameC");
}
Any help is much appreciated.
P.S. It doesn’t like lines 7, 9 and 11.