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