I’m passing a bool
to a method in another class by reference, so that I can change it (-the original argument) from within the method.
I also want an event (which is subscribed to by that method) to be able to change it.
Doing this:
class myCheckBox : CheckBox
{
bool b1;
public myCheckBox(ref bool b)
{
b1 = b;
this.CheckedChanged += new EventHandler(myCheckBox_CheckedChanged);
}
void myCheckBox_CheckedChanged(object sender, EventArgs e)
{
b1 = Checked;
}
}
doesn’t help, since b1 is only a copy of b.
Is there any way of doing: ref b1 = ref b;
? if not, how do I solve this?
(The examples are only to explain the question.)