MemoryStream.Capacity プロパティ

定義

ストリームに割り当てられたバイト数を取得または設定します。

public:
 virtual property int Capacity { int get(); void set(int value); };
public virtual int Capacity { get; set; }
member this.Capacity : int with get, set
Public Overridable Property Capacity As Integer

プロパティ値

ストリームに対してバッファーが使用できる部分の長さ。

例外

容量が負の値または現在のストリーム長より小さい値に設定されています。

現在のストリームが閉じられます。

容量を変更できないストリームに対して set が呼び出されました。

このコード例は、MemoryStream クラスのために提供されている大規模な例の一部です。

// Write the stream properties to the console.
Console::WriteLine( "Capacity = {0}, Length = {1}, "
"Position = {2}\n", memStream->Capacity.ToString(), memStream->Length.ToString(), memStream->Position.ToString() );
// Write the stream properties to the console.
Console.WriteLine(
    "Capacity = {0}, Length = {1}, Position = {2}\n",
    memStream.Capacity.ToString(),
    memStream.Length.ToString(),
    memStream.Position.ToString());
' Write the stream properties to the console.
Console.WriteLine( _
    "Capacity = {0}, Length = {1}, Position = {2}", _
    memStream.Capacity.ToString(), _
    memStream.Length.ToString(), _
    memStream.Position.ToString())

注釈

Capacity は、システム提供のバイト配列のバッファー長です。 Capacity をストリームの現在の長さより小さい値に設定することはできません。

適用対象

こちらもご覧ください