A static method that returns a Boolean value. : bool « Data Types « C# / C Sharp






A static method that returns a Boolean value.

    

using System;

class MainClass{

    public static Boolean TestInput(int val) {
        if (val < 1 || val > 10)
            return false;
        return true;
    }

    public static void Main() {
        Console.WriteLine("TestInput(0) = {0}", TestInput(0));
        Console.WriteLine("TestInput(1) = {0}", TestInput(1));
        Console.WriteLine("TestInput(5) = {0}", TestInput(5));
        Console.WriteLine("TestInput(11) = {0}", TestInput(11));
    }
}

   
    
    
  








Related examples in the same category

1.bool variable
2.Using BoolUsing Bool
3.Demonstrate bool valuesDemonstrate bool values
4.Print a truth table for the logical operatorsPrint a truth table for the logical operators
5.bool FalseString, TrueString
6.Convert boolean value to "Yes" or "No"
7.Converts string to Boolean, throws an exception if not compatible
8.Convert string to Boolean. A return value indicates whether the conversion succeeded or failed.
9.Convert text values to boolean