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