/* This code doesn't work because I don't know how to use the return from boolean Methode in the 'if' statement in Main.
Actually we're learning how to use Methods, that's why... It could be easier without Methode.
What's wrong here? Please help*/
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please type here the year to check: ");
int year = int.Parse(Console.ReadLine());
if (CheckLeapYear () = true)
{
Console.WriteLine("This is a leap year!");
}
Console.WriteLine(year + " is not a leap year");
Console.ReadLine();
}
public static bool CheckLeapYear(int x)
{
if ((x % 400 == 0) || (x % 100 == 0) || (x % 4 == 0))
{
//Console.WriteLine(x + " is a leap year");
return true;
}
return false;
}
{
static void Main(string[] args)
{
Console.WriteLine("Please type here the year to check: ");
int year = int.Parse(Console.ReadLine());
if (CheckLeapYear () = true)
{
Console.WriteLine("This is a leap year!");
}
Console.WriteLine(year + " is not a leap year");
Console.ReadLine();
}
public static bool CheckLeapYear(int x)
{
if ((x % 400 == 0) || (x % 100 == 0) || (x % 4 == 0))
{
//Console.WriteLine(x + " is a leap year");
return true;
}
return false;
}

Nitin SontakkeRank #264 · 9.6K reputationPosted Apr 8, 2018, 1:09 AM EDT
Catcher WongRank #286 · 8.8K reputationPosted Apr 7, 2018, 4:59 PM EDT
Rafnas T PRank #280 · 8.8K reputationPosted Apr 7, 2018, 9:25 PM EDT
Mira Mamatoktorova7 reputationPosted Apr 7, 2018, 11:30 PM EDT