小编Mel*_*oot的帖子

名称门在当前上下文中不存在

我正在编写一个小程序控制台程序,询问姓名和年龄,然后确定你是否已经足够大了.我尝试使用变量来确定此人是否可以继续:

Bool door = true;
Run Code Online (Sandbox Code Playgroud)

然后我想问那些因年龄而被拒绝的人,如果他们想再次填写.

if (door == false){
  Console.WriteLine("Wilt u op nieuw uw leeftijd invullen?");
}
Run Code Online (Sandbox Code Playgroud)

但是Visual Studio给出了以下错误:

错误CS0103当前上下文ConsoleApplication1中不存在名称"door"

这是完整的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Hallo, wie ben jij? ");
            string Name = Convert.ToString (Console.ReadLine());
            Console.Write("Hallo " + Name + ", hoe oud ben jij? ");
            int Age = Convert.ToInt32 (Console.ReadLine());
            Console.ReadLine();

            if (Age < 18) {
                int remaining = 18 - …
Run Code Online (Sandbox Code Playgroud)

c# console visual-studio

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

标签 统计

c# ×1

console ×1

visual-studio ×1