shuffle数字游戏的随机播放代码出错

时间:2014-06-23 17:11:49

标签: c#

if (same)
{
    MessageBoxButtons.AbortRetryIgnore("You have finished the game in " + Hits.ToString() + " hits", "End of Game", 2);
}

MessageBoxButtons.AbortRetryIgnore出现错误 - 显示不可调用的成员MessageBoxButtons.AbortRetryIgnore不能像方法一样使用。

我该怎么做才能解决这个问题?

2 个答案:

答案 0 :(得分:2)

MessageBoxButtons是一个枚举。发生此错误是因为您尝试错误地将其AbortRetryIgnore值作为方法调用,这是不可能的。您需要使用MessageBox.Show

MessageBox.Show(
    "You have finished the game in " + Hits.ToString() + " hits",
    "End of Game",
    MessageBoxButtons.AbortRetryIgnore);

答案 1 :(得分:0)

MessageBoxButtons是一个枚举,因此不能像方法一样调用它的成员。

您正在寻找MessageBox.Show的{​​{3}}重载。代码看起来像:

MessageBox.Show("You have finished the game in " + Hits.ToString() + " hits", "End of Game", "End of Game!", MessageBoxButtons.AbortRetryIgnore);

请注意,您通常会使用String.Format而不是字符串连接。