Mono Class Library: System.IO.MemoryStream Overview | Members

System.IO.MemoryStream.Capacity Property

Gets or sets the number of bytes allocated for the current stream. [Edit]

public virtual int Capacity { set; get; }

Value

A int containing the number of bytes allocated for the current stream. [Edit]

Exceptions

TypeReason
ArgumentOutOfRangeExceptionThe value specified for a set operation is negative or less than the current length of the stream. [Edit]
NotSupportedExceptionA set operation was attempted on a stream whose capacity cannot be modified. [Edit]
ObjectDisposedExceptionThe current stream is closed. [Edit]

Remarks

MemoryStream.Capacity is the buffer length for system-provided byte arrays. If the current stream is created with a specified byte array, MemoryStream.Capacity indicates the length of the portion of the provided array to which the current stream has access.

Note: For additional information, see the System.IO.MemoryStream (byte[], int, int ) constructor.

MemoryStream.Capacity cannot be set to a value less than the current length of the stream, but can be set to less than the current capacity. If the capacity specified is less than the current capacity, the size of the buffer used to hold the stream can be reduced, but need not be.

Note: If the value specified for a set operation is less than the default value, for performance reasons the property is set to the default. The default value of the MemoryStream.Capacity property is unspecified.

Operation
As described above.

[Edit]

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0