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
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
c# bool to int
bool t = true;
bool f = false;
var a = Unsafe.As<bool, int>(ref t);
var b = Unsafe.As<bool, int>(ref f);
Console.WriteLine(a); // 1
Console.WriteLine(b); // 0
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us