CS1513 C#}预期错误

时间:2017-07-13 12:48:53

标签: c#

我真的知道编程,所以请好好哈哈。原谅" Noob"问题,我现在正在试验。任何人都可以给我一些关于导致什么的提示

CS1513  C# } expected

我的代码是:

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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            string country = "USA";
            Console.WriteLine("Hello, What country are you from?");
            string countryName = Convert.ToString(Console.ReadLine());
            if (countryName == country) ;
            {
                Console.WriteLine("You are Eligable for the competition ! :-) ");
            } 
            else {
                Console.WriteLine("You are not Eligable, Sorry!!");
            }

        }
    }
}

我试图基本上根据用户的国家给出答案。

2 个答案:

答案 0 :(得分:3)

删除;来自if(countryName == country);

;是一个声明终结者。见why do some lines not have semicolon in C#?

答案 1 :(得分:0)

您在;声明后添加了if

应该是if (countryName == country)而不是if (countryName == country) ;