C# BitConverter GetBytes(Char)

Description

BitConverter GetBytes(Char) returns the specified Unicode character value as an array of bytes.

Syntax

BitConverter.GetBytes(Char) has the following syntax.


public static byte[] GetBytes(
  char value
)

Parameters

BitConverter.GetBytes(Char) has the following parameters.

  • value - A character to convert.

Returns

BitConverter.GetBytes(Char) method returns

Example

The following code example converts the bit patterns of Char values (Unicode characters) to Byte arrays with the GetBytes method.


/*from  w  w  w .j  ava 2  s.  c o m*/

using System;

class GetBytesUInt64Demo
{

    public static void Main( )
    {
        byte[ ] byteArray = BitConverter.GetBytes( 'a' );
        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