<Type Name="Buffer" FullName="System.Buffer">
  <TypeSignature Maintainer="auto" Language="C#" Value="public static class Buffer" />
  <AssemblyInfo>
    <AssemblyName>mscorlib</AssemblyName>
    <AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00]</AssemblyPublicKey>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <ThreadSafetyStatement>Gtk# is thread aware, but not thread safe; See the &lt;link location="node:gtk-sharp/programming/threads"&gt;Gtk# Thread Programming&lt;/link&gt; for details.</ThreadSafetyStatement>
  <Base>
    <BaseTypeName>System.Object</BaseTypeName>
  </Base>
  <Interfaces />
  <Docs>
    <summary>A low level array manipulation class. Allows bytewise reading and writing on the primitive types contained in an array.</summary>
    <remarks>Using this class it is possible to access arrays of primitive types on byte level. For example an integer array declared as <code lang="C#">int[] arr = new int[10];</code> is lined up in memory as 10 consecutive 32 bit integers. This class can access the individual bytes, and hence circumvents any byte order abstractions.

The following example shows how to use most methods of this class.
<example><code lang="C#">
using System;
using System.Text;

public class BufferTest {
        public static void Main (string[] args)
        {
                int[] arr1 = { 65, 66, 67, 68, 69, };
                byte[] arr2 = new byte[16];

                // prints "arr1 length in bytes is 20" (5 * 4)
                Console.WriteLine ("arr1 length in bytes is {0}",
                        Buffer.ByteLength (arr1));
                Buffer.BlockCopy (arr1, 1, arr2, 0, 12);

                // prints "BCD" (which is 66, 67, 68).
                // The NUL inbetween bytes are skipped.
                Console.WriteLine (Encoding.ASCII.GetString (arr2));

                // note that the following is endian dependant
                StringBuilder byteStr = new StringBuilder ();
                for (int n = 0 ; n &lt; Buffer.ByteLength (arr1) ; ++n) {
                        byte b = Buffer.GetByte (arr1, n);

                        byteStr.Append ("0123456789abcdef"[b &gt;&gt; 4]);
                        byteStr.Append ("0123456789abcdef"[b &amp; 0xf]);
                        byteStr.Append (" ");
                }

                Console.WriteLine ("hexdump of arr1: {0}", byteStr);
        }
}</code></example></remarks>
  </Docs>
  <Members>
    <Member MemberName="BlockCopy">
      <MemberSignature Language="C#" Value="public static void BlockCopy (Array src, int srcOffset, Array dest, int destOffset, int count);" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="src" Type="System.Array" />
        <Parameter Name="srcOffset" Type="System.Int32" />
        <Parameter Name="dest" Type="System.Array" />
        <Parameter Name="destOffset" Type="System.Int32" />
        <Parameter Name="count" Type="System.Int32" />
      </Parameters>
      <Docs>
        <param name="src">The source <see cref="T:System.Array" /> the byte data is copied from.</param>
        <param name="srcOffset">The non-negative integer index from where the copying starts in the source array.</param>
        <param name="dest">To be added.</param>
        <param name="destOffset">To be added.</param>
        <param name="count">The number of bytes to copy.</param>
        <param name="dst">The non-negative destination <see cref="T:System.Array" /> the byte block is copied into. It has to be sufficiently long.</param>
        <param name="dstOffset">The non-negative destination index into the destination array. It has to be within the array's length.</param>
        <summary>Copy a block of data on the byte level between two arrays.</summary>
        <remarks>Copy count bytes starting from the srcOffset position in the src array to the dstOffset position in the dst array. The source and destination arrays do not have to share the same type, but they are both treated as linear byte array. The indexes to the copy operation are at byte level and do not have to be aligned on the primitive type's boundaries.</remarks>
      </Docs>
    </Member>
    <Member MemberName="ByteLength">
      <MemberSignature Language="C#" Value="public static int ByteLength (Array array);" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Int32</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="array" Type="System.Array" />
      </Parameters>
      <Docs>
        <param name="array">The array whose length in bytes should be determined.</param>
        <summary>Give the length of an <see cref="T:System.Arrray" /> in bytes.</summary>
        <returns>The length in bytes.</returns>
        <remarks />
      </Docs>
    </Member>
    <Member MemberName="GetByte">
      <MemberSignature Language="C#" Value="public static byte GetByte (Array array, int index);" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Byte</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="array" Type="System.Array" />
        <Parameter Name="index" Type="System.Int32" />
      </Parameters>
      <Docs>
        <param name="array">The array to be read from.</param>
        <param name="index">The byte level index into the array from which should be read. Must be inbetween 0 and <see cref="M:System.Buffer.ByteLength(System.Array)" />-1.</param>
        <summary>Give a single byte from within an array.</summary>
        <returns>The single byte read from array at index.</returns>
        <remarks />
      </Docs>
    </Member>
    <Member MemberName="SetByte">
      <MemberSignature Language="C#" Value="public static void SetByte (Array array, int index, byte value);" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="array" Type="System.Array" />
        <Parameter Name="index" Type="System.Int32" />
        <Parameter Name="value" Type="System.Byte" />
      </Parameters>
      <Docs>
        <param name="array">The array which is to be modified.</param>
        <param name="index">The byte position within the array whose content should be modified.</param>
        <param name="value">The new value.</param>
        <summary>Set a single byte in an array to a specified value.</summary>
        <remarks>Set the index'th byte of array to value.</remarks>
      </Docs>
    </Member>
  </Members>
</Type>
