C# Convert ToBoolean() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Convert

Definition

In C#, Convert.ToBoolean produces a bool from many input types. String forms accept "True" and "False" without caring about letter case.

Numeric inputs treat zero as false and any other number as true. Prefer this when you already have an object or mixed source; for plain strings you can also use bool.Parse / bool.TryParse.

This is a static member of System.Convert. You call it with the type name, such as Convert.ToBoolean(...). Convert is the everyday API for converting between common CLR types in C#.

Syntax

Pass a string, number, or other convertible value.

C#
bool a = Convert.ToBoolean("True");
bool b = Convert.ToBoolean(1);
bool c = Convert.ToBoolean(0);
CallWhat it does
Convert.ToBoolean("true")Case-insensitive True/False text.
Convert.ToBoolean(1)Non-zero number → true.
Convert.ToBoolean(0)Zero → false.

Invalid strings such as "yes" throw FormatException. null becomes false for the object overload.

Library declarations
C#
public static bool ToBoolean(string? value);
public static bool ToBoolean(int value);
public static bool ToBoolean(object? value);

Parameters

ParameterDescription
valueRequired. String ("True"/"False"), number, or other convertible value.

Return Value

Return ValueDescription
booltrue or false after conversion.

C# Examples

Example 1 — Read True/False Text

Convert case variants of True and False.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine(Convert.ToBoolean("True"));
        Console.WriteLine(Convert.ToBoolean("false"));
        Console.WriteLine(Convert.ToBoolean("TRUE"));
    }
}

How It Works

  1. Exact words. Only True/False spellings (any case) are accepted as bool text.
  2. Case ignored. "false" and "TRUE" both parse correctly.
  3. Printed form. Console shows capitalized True/False.
  4. Not yes/no. Words like "yes" throw FormatException.

Example 2 — Zero Means False

Map integer flags to bool with ToBoolean.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine(Convert.ToBoolean(0));
        Console.WriteLine(Convert.ToBoolean(1));
        Console.WriteLine(Convert.ToBoolean(-3));
    }
}

How It Works

  1. Zero rule. Numeric zero becomes false.
  2. Any other. Positive or negative non-zero becomes true.
  3. Flag style. Useful when a database column stores 0/1.
  4. Still a bool. The return type is bool, ready for if tests.

Example 3 — Object Overload and Null

Convert boxed values and see null become false.

C#
using System;

class Program {
    static void Main() {
        object flag = true;
        object missing = null;
        Console.WriteLine(Convert.ToBoolean(flag));
        Console.WriteLine(Convert.ToBoolean(missing));
    }
}

How It Works

  1. Boxed bool. An object holding true converts cleanly.
  2. Null → false. The object overload treats null as false.
  3. Unlike Parse. bool.Parse cannot accept null.
  4. Mixed sources. Handy when values arrive as object from APIs.

Frequently Asked Questions

Yes. True/False matching is case-insensitive.
That throws FormatException. Only True/False text forms are valid.
For the object overload, yes. Prefer TryParse when you need to detect missing input separately.
Yes. 0 is false; any other number is true.
Parse is strict on null. Convert is convenient for object/null-friendly paths.

Next: ToByte()

Convert a value to byte (0–255). Overflow and bad format throw with System.Convert.

ToByte() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful