Class ByteArrayContent
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
intcount
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 thecontent
parameter.-or-
The
count
parameter is less than zero.-or-
The
count
parameter is greater than the length of content specified by thecontent
parameter - minus theoffset
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
StreamThe 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
longThe length in bytes of the HTTP content.