Mono Class Library: System.Convert Overview | Members

System.Convert.ToBoolean Method

Converts a ulong to a bool . [Edit]

[System.CLSCompliant(false)]
public static bool ToBoolean (ulong value)

Parameters

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

Returns

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

Remarks

This member is not CLS-compliant. For a CLS-compliant alternative, use Convert.ToBoolean(object)(decimal). [Edit]

Example

The following example demonstrates converting ulong values to bool values.

C# Example
using System;
class ConvertBoolTest {
    static public void Main() {
        ulong ulong0 = 0;
        ulong ulong1 = 1; 
        bool bool0 = Convert.ToBoolean(ulong0);
        bool bool1 = Convert.ToBoolean(ulong1);
        Console.WriteLine("(ulong) {0} as bool = {1}",ulong0,bool0);
        Console.WriteLine("(ulong) {0} as bool = {1}",ulong1,bool1);
    }
}

The output is

(ulong) 0 as bool = False
(ulong) 1 as bool = True

Requirements

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