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