BitConverter : BitConverter : Development C# Examples


C# Examples » Development » BitConverter »

 

BitConverter





Convert a built-in data type into an array of bytes.




    
public  static  readonly  bool  IsLittleEndian
    
   
  
   

BitConverter is sealed, which means that it cannot be inherited.
Methods Defined by BitConverter



Method
Meaning


public static longDoubleToInt64Bits(double v)
Converts v into a long integer.


public static byte[ ] GetBytes(bool v)
Converts v into a 1-byte array.


public static byte[ ] GetBytes(char v)
Converts v into a 2-byte array.


public static byte[ ] GetBytes(double v)
Converts v into an 8-byte.


public static byte[ ] GetBytes(float v)
Converts v into a 4-byte.


public static byte[ ] GetBytes(int v)
Converts v into a 4-byte.


public static byte[ ] GetBytes(long v)
Converts v into an 8-byte.


public static byte[ ] GetBytes(short v)
Converts v into a 2-byte.


public static byte[ ] GetBytes(uint v)
Converts v into a 4-byte.


public static byte[ ] GetBytes(ulong v)
Converts v into an 8-byte.


public static byte[ ] GetBytes(ushort v)
Converts v into a 2-byte.


public static doubleInt64BitsToDouble(long v)
Converts v into a double floating-point value.


public static bool ToBoolean(byte[ ] a,int idx)
Converts the byte at a[idx] into its bool equivalent. A non-zero value is converted to true; zero is converted to false.


public static char ToChar(byte[ ] a,int start)
Converts two bytes starting at a[start] into its char equivalent.


public static double ToDouble(byte[ ] a,int start)
Converts eight bytes starting at a[start] into its double equivalent.


public static short ToInt16(byte[ ] a,int start)
Converts two bytes starting at a[start] into its short equivalent.


public static int ToInt32(byte[ ] a,int start)
Converts four bytes starting at a[start] into its int equivalent.


public static long ToInt64(byte[ ] a,int start)
Converts eight bytes starting at a[start] into its long equivalent.


public static float ToSingle(byte[ ] a,int start)
Converts four bytes starting at a[start] into its float equivalent.


public static string ToString(byte[ ] a)
Converts the bytes in a into a string. The string contains the hexadecimal values associated with the bytes, separated by hyphens.


public static string ToString(byte[ ] a, int start)
Converts the bytes in a, beginning at a[start], into a string. The string contains the hexadecimal values associated with the bytes, separated by hyphens.


public static string ToString(byte[ ] a, int start, int count)
Converts the bytes in a, beginning at a[start] and running for count bytes, into a string. The string contains the hexadecimal values associated with the bytes, separated by hyphens.


public static ushort ToUInt16(byte[ ] a,int start)
Converts two bytes starting at a[start] into its ushort equivalent and returns the result.


public static uint ToUInt32(byte[ ] a,int start)
Converts four bytes starting at a[start] into its uint equivalent and returns the result.


public static ulong ToUInt64(byte[ ] a,int start)
Converts eight bytes starting at a[start] into its ulong equivalent and returns the result.






HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» BitConverter