c# convert int to boolean code example
Example 1: int to bool c#
int i = 0;
bool b = Convert.ToBoolean(i);
Example 2: c# int to bool
// Simple way, may crash if intValue > 1
int intValue = 1;
bool boolValue = intValue != 0;
// value of boolValue: true
// Better way
int intValue = 1;
bool boolValue = System.Convert.ToBoolean(intValue);
// value of boolValue: true