I'm learning C# right now and for one of the exercises i tried creating an IF statement,but VS 2015 tells me that there's a } missing. I rewrote the script using the IF example on the MSDN website but it still says that..
I gotta write a Console application that tells if the user is whether male or not. A bool variable is in charge. Here's the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace isMale
{
class Program
{
static void Main(string[] args)
{
bool isMale;
Console.WriteLine("Are you male? (Press Y to answer \"Yes\" and N to answer \"No\")");
if (Console.ReadKey().Key != ConsoleKey.Y) ;
{
isMale = true;
} // <--- It tells meh that i have to place an } right here
else ;
{
isMale = false;
}
Console.WriteLine("You are male: " + isMale);
}
}
}
I know it's not much but it really annoys me.
Thank you for viewing and (hopefully) helping and - Have a nice coding day!
Aucun commentaire:
Enregistrer un commentaire