Convert.ToBoolean Method in C#

The Convert.ToBoolean method is used to convert a specified value to an equivalent Boolean value.

The following is our double type.

double doubleNum = 329.34;

To convert it to Boolean, use the Convert.ToBoolean() method.

bool boolNum;
boolNum = System.Convert.ToBoolean(doubleNum);

Let us see another example.


 Live Demo

using System;
public class Demo {
   public static void Main() {
      double doubleNum = 3.4;
      bool boolNum;
      // Double to bool
      boolNum = System.Convert.ToBoolean(doubleNum);
      System.Console.WriteLine("{0} as a Boolean = {1}.", doubleNum, boolNum);


3.4 as a Boolean = True.

Updated on: 23-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started