我尝试检查设置“锦标赛”是否已设置,如果没有设置默认值,则设置为 4。但是当我运行它时,它会崩溃并出现异常:Platform::InvalidCastException ^
无效演员表在哪里?
ApplicationDataCompositeValue^ tournament_composite = safe_cast<ApplicationDataCompositeValue^>(localSettings->Values->Lookup("tournament"));
if (tournament_composite == nullptr)
{
values->Insert("tournament", dynamic_cast<PropertyValue^>(PropertyValue::CreateInt32(4)));
}
else
{
int tournament = safe_cast<IPropertyValue^>(tournament_composite->Lookup("tournament"))->GetInt32();
switch (tournament)
{
case 0:
lb_tournament->SelectedIndex = 4;
break;
case 3:
lb_tournament->SelectedIndex = 0;
break;
case 5:
lb_tournament->SelectedIndex = 1;
break;
case 7:
lb_tournament->SelectedIndex = 2;
break;
case 11:
lb_tournament->SelectedIndex = 3;
break;
default:
lb_tournament->SelectedIndex = 4;
break;
}
}