var response = await App.PhrasespageCS.DisplayAlert("Reset score",
"You have more than 50 points. Are you sure you want to reset it to 0?",
"Yes", "No");
if (response == true)
{
App.DB.ResetPointsForSelectedPhrase(App.cfs);
}
我不清楚在这里使用等待,并希望得到建议。这也可以合并成一个陈述吗?
答案 0 :(得分:1)
Await意味着该应用已经为您创建了一个对话框,并且会等到答案得到回应。 这是写它的正确方法。此外,如果你想减少代码,你可以把它,如下,
if (await App.PhrasespageCS.DisplayAlert("Reset score", "You have more than 50 points.Are you sure you want to reset it to 0 ? ", "Yes", "No"))
App.DB.ResetPointsForSelectedPhrase(App.cfs);
答案 1 :(得分:0)