how to convert bool value to int in c# code example
Example 1: transform bool to int c#
using System;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Convert.ToInt32(true) : " + Convert.ToInt32(true));
Console.WriteLine("Convert.ToInt32(false): " + Convert.ToInt32(false));
Console.ReadLine();
}
}
}
Example 2: c# int to bool
int intValue = 1;
bool boolValue = intValue != 0;
int intValue = 1;
bool boolValue = System.Convert.ToBoolean(intValue);