System.Convert.ToBoolean Method

Converts the value of the specified 64-bit signed integer to an equivalent Boolean value.

Syntax

public static bool ToBoolean (long value)

Parameters

value
The 64-bit signed integer to convert.

Returns

true if value is not zero; otherwise, false.

Remarks

Documentation for this section has not yet been entered.

Example

The following example demonstrates converting long values to bool values.

C# Example

using System;
class ConvertBoolTest {
    static public void Main() {
        long long0 = 0;
        long long1 = 1; 
        long long2 = -2;
        bool bool0 = Convert.ToBoolean(long0);
        bool bool1 = Convert.ToBoolean(long1);
        bool bool2 = Convert.ToBoolean(long2);
        Console.WriteLine("(long) {0} as bool = {1}",long0,bool0);
        Console.WriteLine("(long) {0} as bool = {1}",long1,bool1);
        Console.WriteLine("(long) {0} as bool = {1}",long2,bool2);
    }
}

The output is

(long) 0 as bool = False
(long) 1 as bool = True
(long) -2 as bool = True

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0