Convert byte to Boolean in CSharp

Description

The following code shows how to convert byte to Boolean.

Example


using System;//from w ww . j ava 2  s.  c o m
using System.Globalization;

public class Example
{
   public static void Main()
   {
   
        byte[] bytes = { Byte.MinValue, 100, 200, Byte.MaxValue };
        bool result;
        
        foreach (byte byteValue in bytes)
        {
           result = Convert.ToBoolean(byteValue); 
           Console.WriteLine("{0,-5}  -->  {1}", byteValue, result);
        }           
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var