Table of Contents

Class ByteArrayContent

Namespace
System.Net.Http
Assembly
System.Net.Http.dll

Provides HTTP content based on a byte array.

public class ByteArrayContent : HttpContent, IDisposable
Inheritance
ByteArrayContent
Implements
Derived
Inherited Members
Extension Methods

Constructors

ByteArrayContent(byte[])

Initializes a new instance of the ByteArrayContent class.

public ByteArrayContent(byte[] content)

Parameters

content byte[]

The content used to initialize the ByteArrayContent.

Exceptions

ArgumentNullException

The content parameter is null.

ByteArrayContent(byte[], int, int)

Initializes a new instance of the ByteArrayContent class.

public ByteArrayContent(byte[] content, int offset, int count)

Parameters

content byte[]

The content used to initialize the ByteArrayContent.

offset int
count int

Remarks

Only the range specified by the offset parameter and the count parameter is used as content. Syntax

Exceptions

ArgumentNullException

The content parameter is null.

ArgumentOutOfRangeException

The offset parameter is less than zero.

-or-

The offset parameter is greater than the length of content specified by the content parameter.

-or-

The count parameter is less than zero.

-or-

The count parameter is greater than the length of content specified by the content parameter - minus the offset parameter.

Methods

SerializeToStream(Stream)

When overridden in a derived class, serializes the HTTP content to a stream. Otherwise, throws a NotSupportedException.

protected override void SerializeToStream(Stream stream)

Parameters

stream Stream

The target stream.

Remarks

This is the .NET nanoFramework equivalent of SerializeToStream(Stream, TransportContext, CancellationToken).

Exceptions

NotSupportedException

The method is not overridden in the derived class.

TryComputeLength(out long)

Determines whether the HTTP content has a valid length in bytes.

protected override bool TryComputeLength(out long length)

Parameters

length long

The length in bytes of the HTTP content.

Returns

bool

true if length is a valid length; otherwise, false.