我这段代码:
correctButton.Clicked += (sender, e) =>
{
App.DB.IncrementScore(AS.cfs, AS.phrase);
correctAns++;
AS.pointsCount[(int)AS.cfs]++;
scoreCountLabel.Text = FontAwesome.FAStop.Repeat(correctAns);
Device.StartTimer(TimeSpan.FromSeconds(0.5), () =>
{
switch (AS.cardOrder)
{
case CardOrder.FirstToLast:
AS.orderPhraseIndex++;
AS.phraseIndexList.Add(AS.orderPhraseIndex);
getPhraseFirstToLast();
break;
case CardOrder.Random:
getRandomNumber();
getRandomPhrase();
break;
}
return false;
});
};
我想将运行的代码移到方法中并传递参数。但是如何在单击correctButton时调用该方法?
答案 0 :(得分:2)
correctButton.Clicked += correctButtonClicked;
protected void correctButtonClicked(object sender, EventArgs e)
{
// code goes here
}