【发布时间】:2014-01-23 21:46:57
【问题描述】:
我对 C# 很陌生,每天都在学习它的元素,来自 C 也让我感到困惑,因为像这样的简单 for 循环可以工作,那么为什么它不能在 C# 中工作,如果可以的话详细解释(如果可能的话)我将不胜感激。
for (int i = 1; i <= 10; i++){
public void question()
{
if (questionNr == 1)
{
questionLabel.Text = "What is Chuck's full name?";
ans1.Text = "Charles Irving Bartowski";
ans2.Text = "Charles Richard Bartowski";
ans3.Text = "Charles Luke Bartowski";
ans4.Text = "Zachary Strahovski";
}
else if (questionNr == 2)
{
questionLabel.Text = "Who/what is Orion?";
ans1.Text = "Original name of the Intersect";
ans2.Text = "Alias of a secret mission";
ans3.Text = "Morgan's Xbox";
ans4.Text = "Chuck's father";
}
}
public void ans1_Click(object sender, EventArgs e)
{
if (questionNr == 1)
{
pointCounter++;
pointsLabel.Text = "Current points:" + pointCounter.ToString();
questionNr++;
}
}
private void ans2_Click(object sender, EventArgs e)
{
if (questionNr == 1)
{
questionNr++;
}
}
private void ans3_Click(object sender, EventArgs e)
{
if (questionNr == 1)
{
questionNr++;
}
}
private void ans4_Click(object sender, EventArgs e)
{
if (questionNr == 1)
{
questionNr++;
}
}
}
【问题讨论】:
-
这在 C 中也行不通
-
你要这个做什么?
标签: c# loops for-loop compiler-errors