【发布时间】:2017-07-13 12:48:53
【问题描述】:
我真的很懂编程,所以请多多关照哈哈。原谅“菜鸟”的问题,我现在只是在做实验。任何人都可以给我提示是什么原因
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!!");
}
}
}
}
我试图基本上根据用户所在的国家/地区给出答案。
【问题讨论】:
-
if (countryName == country) ;=>if (countryName == country) -
每个人有时都会做错的事情之一
-
它在哪一行告诉你这个错误发生了?当你有这些信息时,你应该总是包含它!
-
这里给菜鸟的教训不仅仅是“分号是空语句”。 编译器发出警告,解释问题,但您忽略了。这里的教训是新手应该阅读编译器警告。我们把它们放在那里!
标签: c#