How can I use the boolean Method return in the 'if' statemen

Apr 7 2018 7:56 PM
 /* 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;
}

Answers (4)