Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Boolean.CompareTo(Object) Method in C#
The Boolean.CompareTo(Object) method in C# compares this instance to a specified object and returns an integer that indicates their relationship to one another.
Syntax
Following is the syntax −
public int CompareTo (object ob);
Above, the parameter ob is an object to compare to this instance, or null.
Example
Let us now see an example to implement the Boolean.CompareTo(Object) method −
using System;
public class Demo {
public static void Main(){
bool b1 = false;
object b2 = false;
int res = b1.CompareTo(b2);
if (res > 0)
Console.Write("b1 > b2");
else if (res Output
This will produce the following output −
b1 = b2
Advertisements
