【发布时间】:2012-04-20 03:43:43
【问题描述】:
(使用 WPF 应用程序) 当我想将 bool 保存到这样的全局变量时出现错误:
Window msgOne = new Window();
if (Properties.Settings.Default.sound01 == true)
{
msgOne.radioboxSound.IsChecked = true;
}
else
{
msgOne.radioboxSound.IsChecked = false;
}
msgOne.ShowDialog();
//waiting for close
Properties.Settings.Default.sound01 = msgOne.radioboxSound.IsChecked;
radioboxSound 是复选框,Properties.Settings.Default.sound01 是全局参数,您可以在 VB c# 的设置选项卡中进行设置
我在上面片段的最后一个链接中得到的错误): 不能隐式转换类型“bool”? “布尔”。存在显式转换(您是否缺少演员表?)
但我没有使用任何 bool?,只有已设置的 bool。
有人知道怎么处理这个吗?
感谢
【问题讨论】:
-
你确实使用了 Nullable
(又名 bool?),因为 IsChecked 是一个。
标签: c# wpf global-variables boolean