它不起作用的原因是因为您将Form2.booly
实例设置为 false 而不是Properties.Settings...
. 值得一提的booly
是,如果您来自 C++,这不是一个指针,因此您应该将方法更改为此。Properties.Settings.Default.booly
private void formB_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.booly = false;
}
一个简单的示例/测试方法是:
static void Main(string[] args)
{
bool valueA = true;
bool valueB = valueA;
// Both will print TRUE
Console.WriteLine("ValueA is: " + valueA.ToString());
Console.WriteLine("ValueB is: " + valueB.ToString());
// Change valueA but leave valueB unchanged
valueA = false;
// valueA now FALSE while valueB is still TRUE
Console.WriteLine("ValueA is: " + valueA.ToString());
Console.WriteLine("ValueB is: " + valueB.ToString());
Console.ReadKey();
}
所以代码片段的最终输出将是:
Value A is: True
Value B is: True
Value A is: False
Value B is: True