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);
Call
What 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
Parameter
Description
value
Required. String ("True"/"False"), number, or other convertible value.
Return Value
Return Value
Description
bool
true 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"));
}
}
Output
True
False
True
How It Works
Exact words. Only True/False spellings (any case) are accepted as bool text.
Case ignored."false" and "TRUE" both parse correctly.
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));
}
}
Output
False
True
True
How It Works
Zero rule. Numeric zero becomes false.
Any other. Positive or negative non-zero becomes true.
Flag style. Useful when a database column stores 0/1.
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));
}
}
Output
True
False
How It Works
Boxed bool. An object holding true converts cleanly.
Null → false. The object overload treats null as false.
Unlike Parse.bool.Parse cannot accept null.
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.