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 을 스트림의 현재 길이보다 작은 값으로 설정할 수 없습니다.

적용 대상

추가 정보