Mono Class Library: System.Convert Overview | Members

System.Convert.ToBoolean Method

Converts a long to a bool . [Edit]

public static bool ToBoolean (long value)

Parameters

value
The 64-bit signed integer value to be converted. [Edit]

Returns

true if value is non-zero; false if value is zero. [Edit]

Remarks

Documentation for this section has not yet been entered. [Edit]

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