System.Buffer Class

Assembly: Mscorlib.dll
Namespace: System
Summary
Manipulates unmanaged memory represented as arrays of bytes.
C# Syntax:
public sealed class Buffer
Remarks
This class provides methods to copy bytes from one primitive array to another primitive array without respecting types, get a byte from an array, set a byte in an array, and obtain the length of an array.
See also:
System Namespace

System.Buffer Member List:

Public Methods
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.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetByte Retrieves the byte at a specified location in a specified array.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
SetByte Assigns a specified value to a byte at a particular location in a specified array.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Buffer Member Details

Method: BlockCopy(
   Array src,
   int srcOffset,
   Array dst,
   int dstOffset,
   int count
)
Summary
Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset.
C# Syntax:
public static void BlockCopy(
   Array src,
   int srcOffset,
   Array dst,
   int dstOffset,
   int count
);
Parameters:

src

The source buffer.

srcOffset

The byte offset into src.

dst

The destination buffer.

dstOffset

The byte offset into dst.

count

The number of bytes to copy.

Remarks
Copies count bytes from src, beginning at srcOffset, to dst, beginning at dstOffset.

Return to top


Method: ByteLength(
   Array array
)
Summary
Returns the number of bytes in the specified array.
C# Syntax:
public static int ByteLength(
   Array array
);
Parameters:

array

An array.

Return Value:
The number of bytes in the array.
Exceptions
Exception Type Condition
ArgumentNullException array is null.
ArgumentException array is not a primitive.
Example
 int [] arr = new int [5] {0, 1, 2, 3, 4};
 Debug.Assert (Buffer.ByteLength(arr) == 20);
 for (int i = 0; i < Buffer.ByteLength(arr); i++)
   {
   Console.Write(arr[i]);
   }
 //This will print: 00000001000200030004

    

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~Buffer();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetByte(
   Array array,
   int index
)
Summary
Retrieves the byte at a specified location in a specified array.
C# Syntax:
public static byte GetByte(
   Array array,
   int index
);
Parameters:

array

An array.

index

A location in the array.

Return Value:
Returns the index byte in the array.
Exceptions
Exception Type Condition
ArgumentException array is not a primitive.
ArgumentNullException array is null.
ArgumentOutOfRangeException index is negative or greater than the length of array.
Remarks
The GetByte method gets a particular byte out of the array. The array must be an array of primitives.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: SetByte(
   Array array,
   int index,
   byte value
)
Summary
Assigns a specified value to a byte at a particular location in a specified array.
C# Syntax:
public static void SetByte(
   Array array,
   int index,
   byte value
);
Parameters:

array

An array.

index

A location in the array.

value

A value to assign.

Exceptions
Exception Type Condition
ArgumentException array is not a primitive.
ArgumentNullException array is null.
ArgumentOutOfRangeException index is negative or greater than the length of array.
Remarks
array must be an array of primitives.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.