ByteArrayContent.TryComputeLength(Int64) Method

Definition

Determines whether a byte array has a valid length in bytes.

protected public:
 override bool TryComputeLength([Runtime::InteropServices::Out] long % length);
protected internal override bool TryComputeLength (out long length);
override this.TryComputeLength : int64 -> bool
Protected Friend Overrides Function TryComputeLength (ByRef length As Long) As Boolean

Parameters

length
Int64

The length in bytes of the byte array.

Returns

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

Remarks

The TryComputeLength method gives a derived content type the ability to calculate the content length. This is useful for content types which are able to easily calculate the content length. If computing the content length is not possible or expensive (would require the system to buffer the whole content where the serialization would be expensive or require the system to allocate a lot of memory), this method can return false. If this method returns false, this implies that either chunked transfer is needed or the content must get buffered before being sent to the server.

This method always returned true for ByteArrayContent.

Applies to