Answers for "integer to boolean c#"

C#
1

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
Posted by: Guest on March-18-2021
0

int to bool c#

int i = 0;
bool b = Convert.ToBoolean(i);
Posted by: Guest on November-22-2020

C# Answers by Framework

Browse Popular Code Answers by Language