Buffer

Buffer CF 1.0

System (mscorlib.dll) sealed class

The Buffer class provides static methods used to manipulate a region of unmanaged memory as though it were an array of Byte s. Byte arrays are traditionally used in unmanaged code to represent blocks of contiguous memory. This class includes the ByteLength( ) method, which indicates the total number of bytes in an array, and the GetByte( ) and SetByte( ) methods, which allow you to retrieve or set a specific Byte object in an array by specifying a zero-based index. Additionally, the BlockCopy( ) method can be used to move contiguous groups of bytes from one position in a buffer to another.

Note that BlockCopy( ) ignores types when conducting its byte-shuffling operations. If you use BlockCopy( ) to insert an otherwise incompatible type into the buffer, the copy goes through, but unpredictable results will arise later when you try to work with the buffer as its original type. For example, if you use the BlockCopy( ) method to insert an Int32 into an array of String objects, the copy goes through, but the next time the array is accessed, there is no longer a String reference. It is an Int32 , and what the CLR will do at that point is undocumented.

 public sealed class  Buffer  {  // Public Static Methods  public static void  BlockCopy  (Array   src   , int   srcOffset   , Array   dst   , int   dstOffset   ,        int   count   );    public static int  ByteLength  (Array   array   );    public static byte  GetByte  (Array   array   , int   index   );    public static void  SetByte  (Array   array   , int   index   , byte   value   ); } 


C# in a Nutshell
C # in a Nutshell, Second Edition
ISBN: 0596005261
EAN: 2147483647
Year: 2005
Pages: 963

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net