BitConverter : BitConverter « Development « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Development » BitConverter 
14.19.1.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

MethodMeaning
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.


14.19.BitConverter
14.19.1.BitConverter
14.19.2.Convert a bool to a byte array and display
14.19.3.Convert a byte array to a bool and display
14.19.4.Convert an int to a byte array and display
14.19.5.Convert a byte array to an int and display
14.19.6.Convert different data types to byte array and convert byte array back
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.