locked
return true and return false RRS feed

  • Question

  • 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
    • Moved by edhickey Tuesday, May 24, 2011 2:14 PM (From:.NET 3.0/3.5 Windows Workflow Foundation)
    Tuesday, May 24, 2011 1:33 PM

Answers

  • "return true" returns true, "return false" returns false.

    For example:

    bool IsBig(int number)
    {
        if(number > 1000000)
            return true;
        else
            return false;
    }
    
    • Proposed as answer by Seabass008 Tuesday, May 24, 2011 2:41 PM
    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:03 AM
    Tuesday, May 24, 2011 2:31 PM
  • 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
    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:03 AM
    Tuesday, May 24, 2011 3:55 PM
    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:04 AM
    Tuesday, May 24, 2011 7:14 PM
  • 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

    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:04 AM
    Tuesday, May 24, 2011 7:30 PM

All replies

  • "return true" returns true, "return false" returns false.

    For example:

    bool IsBig(int number)
    {
        if(number > 1000000)
            return true;
        else
            return false;
    }
    
    • Proposed as answer by Seabass008 Tuesday, May 24, 2011 2:41 PM
    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:03 AM
    Tuesday, May 24, 2011 2:31 PM
  • 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
    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:03 AM
    Tuesday, May 24, 2011 3:55 PM
    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:04 AM
    Tuesday, May 24, 2011 7:14 PM
  • 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

    • Marked as answer by lucy-liu Tuesday, May 31, 2011 6:04 AM
    Tuesday, May 24, 2011 7:30 PM
  • Thank you Lucy.
    Best Regards, Arjun
    Friday, June 3, 2011 6:34 PM