C# Convert ToBoolean(UInt32)
Description
Convert ToBoolean(UInt32)
converts the value of the
specified 32-bit unsigned integer to an equivalent Boolean value.
Syntax
Convert.ToBoolean(UInt32)
has the following syntax.
[CLSCompliantAttribute(false)]
public static bool ToBoolean(
uint value
)
Parameters
Convert.ToBoolean(UInt32)
has the following parameters.
value
- The 32-bit unsigned integer to convert.
Returns
Convert.ToBoolean(UInt32)
method returns true if value is not zero; otherwise, false.
Example
The following example converts an array of Int32 values to Boolean values.
//from ww w.jav a 2s . c o m
using System;
public class MainClass{
public static void Main(String[] argv){
uint[] numbers = { UInt32.MinValue, 123, 1234567, Int32.MaxValue };
bool result;
foreach (uint number in numbers)
{
result = Convert.ToBoolean(number);
Console.WriteLine("{0,-15:N0} --> {1}", number, result);
}
}
}
The code above generates the following result.