C# BitConverter GetBytes(Boolean)

Description

BitConverter GetBytes(Boolean) returns the specified Boolean value as an array of bytes.

Syntax

BitConverter.GetBytes(Boolean) has the following syntax.


public static byte[] GetBytes(
  bool value
)

Parameters

BitConverter.GetBytes(Boolean) has the following parameters.

  • value - A Boolean value.

Returns

BitConverter.GetBytes(Boolean) method returns

Example

The following code example converts the bit patterns of Boolean values to Byte arrays with the GetBytes method.


/*from   www . j  av  a  2  s . com*/
using System;

class GetBytesUInt64Demo
{

    public static void Main( )
    {
        byte[ ] byteArray = BitConverter.GetBytes( false );
        Console.WriteLine(BitConverter.ToString( byteArray ) );

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version