Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, May 24, 2011 1:33 PM
Hi Friends.....
what is the difference between return true and return false in C#.Net?...and what it returns?.....can someone revert back with a simple example.....
Best Regards, Arjun
All replies (5)
Tuesday, May 24, 2011 2:31 PM ✅Answered | 1 vote
"return true" returns true, "return false" returns false.
For example:
bool IsBig(int number)
{
if(number > 1000000)
return true;
else
return false;
}
Tuesday, May 24, 2011 3:55 PM ✅Answered | 1 vote
True and False are boolean type value on the other hand 1,2 3 are integer value and so on..
suppose you have a form and an input Box fo age.
You want to show a message "your age is under 18" or "your age is above 18" then what you do?
you check some condition, if condition meets then it returns true else false.
// this method returns true or false
bool isAgeGrater18(int age)
{
if(age >18) //when condition meets then returns true
{
return true;
}
else
{
return false;
}
}
hope you are clear.
Hasibul Haque, MCPD http://blog.e-rains.com
Tuesday, May 24, 2011 7:14 PM ✅Answered | 1 vote
In addition to Louis answer.
true : http://msdn.microsoft.com/en-us/library/06d3w013.aspx
false : http://msdn.microsoft.com/en-us/library/x4bbw9d7.aspx
Kind regards,
Tuesday, May 24, 2011 7:30 PM ✅Answered | 1 vote
There is nothing much special in boolan values (true, false). They represent two states, its line 0 and 1 (zero, and one). They come right, when you need to check if something is ok or not.
Mitja
Friday, June 3, 2011 6:34 PM
Thank you Lucy.Best Regards, Arjun