C# BitConverter GetBytes(Int16)
Description
BitConverter GetBytes(Int16)
returns the specified
16-bit signed integer value as an array of bytes.
Syntax
BitConverter.GetBytes(Int16)
has the following syntax.
public static byte[] GetBytes(
short value
)
Parameters
BitConverter.GetBytes(Int16)
has the following parameters.
value
- The number to convert.
Returns
BitConverter.GetBytes(Int16)
method returns
Example
The following code example converts the bit patterns of Int16 values to Byte arrays with the GetBytes method.
/* w w w . ja va 2s. com*/
using System;
class GetBytesUInt64Demo
{
public static void Main( )
{
byte[ ] byteArray = BitConverter.GetBytes( (Int16)1000 );
Console.WriteLine(BitConverter.ToString( byteArray ) );
}
}
The code above generates the following result.