Discovered System.Buffer class that can directly manipulate the bytes of an array class objects. All its members are static.
int[] myarr1 = newint[5] {1,2,3,4,5}; int[] myarr2=newint[10] {0,0,0,0,0,6,7,8,9,10}; //here we are copying offset to offet as bytes Buffer.BlockCopy(myarr1,0,myarr2,0,20);It has 4 members:
- BlockCopy - Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset.
- ByteLength - Returns the number of bytes in the specified array.
- GetByte - Retrieves the byte at a specified location in a specified array.
- SetByte - Assigns a specified value to a byte at a particular location in a specified
System.BitConverter class - Converts base data types to an array of bytes, and an array of bytes to base data types. See 'SelfMarshalledStruct' in OpenNETCF.Net for a sample usage. Works with the System.Buffer class for serialising/deserialising data types to byte arrays.
No comments:
Post a Comment