C# Boolean CompareTo(Boolean)
Description
Boolean CompareTo(Boolean)
compares this instance
to a specified Boolean object and returns an integer that indicates their
relationship to one another.
Syntax
Boolean.CompareTo(Boolean)
has the following syntax.
public int CompareTo(
bool value
)
Parameters
Boolean.CompareTo(Boolean)
has the following parameters.
value
- A Boolean object to compare to this instance.
Returns
Boolean.CompareTo(Boolean)
method returns A signed integer that indicates the relative values of this instance and
value. Return Value Condition Less than zero This instance is false and value
is true. Zero This instance and value are equal (either both are true or both
are false). Greater than zero This instance is true and value is false.
Example
The following code example demonstrates Boolean.CompareTo(Boolean).
using System;/* w ww . j a v a2s . c o m*/
class Sample
{
public static void Main()
{
Boolean a1 = true, a2 = true;
Console.WriteLine(a1.CompareTo(a2));
}
}
The code above generates the following result.