Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我不断得到错误';CS1513:}预期为';在我的节目上_C# - Fatal编程技术网

C# 我不断得到错误';CS1513:}预期为';在我的节目上

C# 我不断得到错误';CS1513:}预期为';在我的节目上,c#,C#,这是我的密码。当我运行这段代码时,它一直给我错误“CS1513:}预期”。我的代码有什么问题?如果这是您的完整程序,那么您在结尾处缺少三个一个关闭Main方法一个关闭程序类和一个关闭控制台应用程序3命名空间。还有一个。} 编译器需要一个未找到的右大括号(}) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; nam

这是我的密码。当我运行这段代码时,它一直给我错误“CS1513:}预期”。我的代码有什么问题?

如果这是您的完整程序,那么您在结尾处缺少三个
一个关闭
Main
方法一个关闭
程序
类和一个关闭
控制台应用程序3
命名空间。还有一个
if
语句后添加code>。

} 编译器需要一个未找到的右大括号(})

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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int age = Convert.ToInt32(Console.ReadLine());

            if (age > 18) ;

                Console.WriteLine("Welcome!");

            else

                Console.WriteLine("You are too young!");

您有多少开放式括号,需要关闭它们。对于上面的代码,在其末尾添加以下内容

// CS1513
namespace y   // CS1513, no close curly brace
{
   class x
   {
      public static void Main()
      {
      }
   }
}

在(年龄>18岁)分号无效后移除分号。
  }}}