C# Convert ToBoolean(Byte)
Description
Convert ToBoolean(Byte)
converts the value of the specified
8-bit unsigned integer to an equivalent Boolean value.
Syntax
Convert.ToBoolean(Byte)
has the following syntax.
public static bool ToBoolean(
byte value
)
Parameters
Convert.ToBoolean(Byte)
has the following parameters.
value
- The 8-bit unsigned integer to convert.
Returns
Convert.ToBoolean(Byte)
method returns true if value is not zero; otherwise, false.
Example
The following example converts an array of Byte values to Boolean values.
/*from ww w. j av a 2 s .com*/
using System;
public class MainClass{
public static void Main(String[] argv){
byte[] bytes = { Byte.MinValue, 10, 200, Byte.MaxValue };
bool result;
foreach (byte byteValue in bytes)
{
result = Convert.ToBoolean(byteValue);
Console.WriteLine("{0,-5} --> {1}", byteValue, result);
}
}
}
The code above generates the following result.