TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mira Mamatoktorova
NA
9
777
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;
}
Reply
Answers (
4
)
Article is not published yet.
Better? - Language (C#) or Technology (MVC) Certfication