-1

I am really knew to programming so please be nice haha. Excuse the "Noob" Question, I'm just experimenting right now. Can anyone give me tips on what is causing

CS1513  C# } expected

My code is:

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!!");
            }

        }
    }
}

I'm trying to give an answer based on the country of the user basically.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
  • 3
    ```if (countryName == country) ;``` => ```if (countryName == country)``` – tym32167 Jul 13 '17 at 12:49
  • One of the things everyone does wrong sometimes – Tom Doodler Jul 13 '17 at 12:51
  • 1
    At what line did it tell you this error was occuring? You should always include this information when you have it available! – Chris Jul 13 '17 at 12:51
  • The lesson here for the noob is not just "a semicolon is an empty statement". **You got a warning from the compiler explaining the problem, which you ignored**. The lesson here is **noobs should read the compiler warnings**. We put them in there for you! – Eric Lippert Jul 13 '17 at 13:53

2 Answers2

3

Remove the ; from if (countryName == country) ;

The ; is a statement terminator. See why do some lines not have semicolon in C#?

ACS
  • 94
  • 1
  • 1
  • 6
0

You put a ; after your if statement.

It should be if (countryName == country) instead of if (countryName == country) ;

Maxime
  • 2,192
  • 1
  • 18
  • 23