小编Szy*_*zki的帖子

c#类,结构或接口成员声明中的'while'无效标记(while循环不起作用)

我是c#的新手但对c非常熟悉,但这个错误对我来说没有多大意义,因为我已经特别遵循了http://msdn.microsoft.com/en-us/library/上显示的所需语法.2aeyhxcd.aspx

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
    int years = 1;
    while (years <=10) {

    public Form1()
    {
        InitializeComponent();
    }

    private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    {
        int value = Convert.ToInt32(bushels1.Text);
        numericUpDown1.Maximum = value;
    }

    private void bushels1_Click(object sender, EventArgs e)
    {

    }

    private void nextYear_Click(object sender, EventArgs e)
    {

    }
    }
   }
}
Run Code Online (Sandbox Code Playgroud)

c# loops while-loop

3
推荐指数
1
解决办法
2269
查看次数

什么是C#方式相当于这个for循环?

我是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";
        } …
Run Code Online (Sandbox Code Playgroud)

c# loops for-loop compiler-errors

-6
推荐指数
2
解决办法
250
查看次数

标签 统计

c# ×2

loops ×2

compiler-errors ×1

for-loop ×1

while-loop ×1