class BitConverter
Converts base data types to an array of bytes, and an array of bytes to base data types.
public static long DoubleToInt64Bits( double value )
Converts the specified double-precision floating point number to a 64-bit signed integer.
valueThe number to convert.- Returns A 64-bit signed integer whose value is equivalent to .
public static byte[] GetBytes( bool value )
Returns the specified Boolean value as a byte array.
valueA Boolean value.- Returns A byte array with length 1.
public static byte[] GetBytes( char value )
Returns the specified Unicode character value as an array of bytes.
valueA character to convert.- Returns An array of bytes with length 2.
public static byte[] GetBytes( double value )
Returns the specified double-precision floating point value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 8.
public static byte[] GetBytes( short value )
Returns the specified 16-bit signed integer value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 2.
public static byte[] GetBytes( int value )
Returns the specified 32-bit signed integer value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 4.
public static byte[] GetBytes( long value )
Returns the specified 64-bit signed integer value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 8.
public static byte[] GetBytes( float value )
Returns the specified single-precision floating point value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 4.
public static byte[] GetBytes( ushort value )
Returns the specified 16-bit unsigned integer value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 2.
public static byte[] GetBytes( uint value )
Returns the specified 32-bit unsigned integer value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 4.
public static byte[] GetBytes( ulong value )
Returns the specified 64-bit unsigned integer value as an array of bytes.
valueThe number to convert.- Returns An array of bytes with length 8.
public static float Int32BitsToSingle( int value )
No summary.
public static double Int64BitsToDouble( long value )
Converts the specified 64-bit signed integer to a double-precision floating point number.
valueThe number to convert.- Returns A double-precision floating point number whose value is equivalent to .
public static bool IsLittleEndian
Indicates the byte order ("endianness") in which data is stored in this computer architecture.
public static int SingleToInt32Bits( float value )
No summary.
public static bool ToBoolean( byte[] value, int startIndex )
Returns a Boolean value converted from the byte at a specified position in a byte array.
valueA byte array.startIndexThe index of the byte within .- Returns if the byte at in is nonzero; otherwise, .
public static char ToChar( byte[] value, int startIndex )
Returns a Unicode character converted from two bytes at a specified position in a byte array.
valueAn array.startIndexThe starting position within .- Returns A character formed by two bytes beginning at .
public static double ToDouble( byte[] value, int startIndex )
Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array.
valueAn array of bytes.startIndexThe starting position within .- Returns A double precision floating point number formed by eight bytes beginning at .
public static short ToInt16( byte[] value, int startIndex )
Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.
valueAn array of bytes.startIndexThe starting position within .- Returns A 16-bit signed integer formed by two bytes beginning at .
public static int ToInt32( byte[] value, int startIndex )
Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.
valueAn array of bytes.startIndexThe starting position within .- Returns A 32-bit signed integer formed by four bytes beginning at .
public static long ToInt64( byte[] value, int startIndex )
Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.
valueAn array of bytes.startIndexThe starting position within .- Returns A 64-bit signed integer formed by eight bytes beginning at .
public static float ToSingle( byte[] value, int startIndex )
Returns a single-precision floating point number converted from four bytes at a specified position in a byte array.
valueAn array of bytes.startIndexThe starting position within .- Returns A single-precision floating point number formed by four bytes beginning at .
public static string ToString( byte[] value )
Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation.
valueAn array of bytes.- Returns A string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in ; for example, "7F-2C-4A-00".
public static string ToString( byte[] value, int startIndex )
Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation.
valueAn array of bytes.startIndexThe starting position within .- Returns A string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of ; for example, "7F-2C-4A-00".
public static string ToString( byte[] value, int startIndex, int length )
Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation.
valueAn array of bytes.startIndexThe starting position within .lengthThe number of array elements in to convert.- Returns A string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of ; for example, "7F-2C-4A-00".
public static ushort ToUInt16( byte[] value, int startIndex )
Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.
valueThe array of bytes.startIndexThe starting position within .- Returns A 16-bit unsigned integer formed by two bytes beginning at .
public static uint ToUInt32( byte[] value, int startIndex )
Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.
valueAn array of bytes.startIndexThe starting position within .- Returns A 32-bit unsigned integer formed by four bytes beginning at .
public static ulong ToUInt64( byte[] value, int startIndex )
Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.
valueAn array of bytes.startIndexThe starting position within .- Returns A 64-bit unsigned integer formed by the eight bytes beginning at .
public static Int128 ToInt128( ReadOnlySpan<byte> value )
😔 No documentation found.
public bool Equals( object obj )
😔 No documentation found.
public static double ToDouble( ReadOnlySpan<byte> value )
😔 No documentation found.
public string ToString( )
😔 No documentation found.
public static bool ToBoolean( ReadOnlySpan<byte> value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, short value )
😔 No documentation found.
public Type GetType( )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, char value )
😔 No documentation found.
public static Half UInt16BitsToHalf( ushort value )
😔 No documentation found.
public static float ToSingle( ReadOnlySpan<byte> value )
😔 No documentation found.
public static ushort HalfToUInt16Bits( Half value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, bool value )
😔 No documentation found.
public static float UInt32BitsToSingle( uint value )
😔 No documentation found.
public static short HalfToInt16Bits( Half value )
😔 No documentation found.
public static Half Int16BitsToHalf( short value )
😔 No documentation found.
public static ulong DoubleToUInt64Bits( double value )
😔 No documentation found.
public static uint SingleToUInt32Bits( float value )
😔 No documentation found.
public static double UInt64BitsToDouble( ulong value )
😔 No documentation found.
public static UInt128 ToUInt128( byte[] value, int startIndex )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, Int128 value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, uint value )
😔 No documentation found.
public static byte[] GetBytes( Int128 value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, ulong value )
😔 No documentation found.
public static byte[] GetBytes( UInt128 value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, UInt128 value )
😔 No documentation found.
public static byte[] GetBytes( Half value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, Half value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, long value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, float value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, int value )
😔 No documentation found.
public static Half ToHalf( ReadOnlySpan<byte> value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, double value )
😔 No documentation found.
public static short ToInt16( ReadOnlySpan<byte> value )
😔 No documentation found.
public static int ToInt32( ReadOnlySpan<byte> value )
😔 No documentation found.
public static long ToInt64( ReadOnlySpan<byte> value )
😔 No documentation found.
public static Int128 ToInt128( byte[] value, int startIndex )
😔 No documentation found.
public int GetHashCode( )
😔 No documentation found.
public static ushort ToUInt16( ReadOnlySpan<byte> value )
😔 No documentation found.
public static uint ToUInt32( ReadOnlySpan<byte> value )
😔 No documentation found.
public static ulong ToUInt64( ReadOnlySpan<byte> value )
😔 No documentation found.
public static bool TryWriteBytes( Span<byte> destination, ushort value )
😔 No documentation found.
public static UInt128 ToUInt128( ReadOnlySpan<byte> value )
😔 No documentation found.
public static char ToChar( ReadOnlySpan<byte> value )
😔 No documentation found.
public static Half ToHalf( byte[] value, int startIndex )
😔 No documentation found.