为什么会这样:
ComboBox cb = sender as ComboBox;
int validSelection = Convert.ToInt32(cb.Tag);
if (cb.SelectedIndex != validSelection) {
cb.SelectedIndex = validSelection;
}
...但是这个:
ComboBox cb = sender as ComboBox;
int validSelection = (int)cb.Tag; // <-- fails
if (cb.SelectedIndex != validSelection) {
cb.SelectedIndex = validSelection;
}
...“对象未设置为对象的引用”的错误?