ByteArrayContent.TryComputeLength(Int64) 方法

定義

判斷位元組陣列是否有有效的位元組長度。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

參數

length
Int64

位元組陣列的位元組長度。The length in bytes of the byte array.

傳回

length 為有效的長度則為 true;否則為 falsetrue if length is a valid length; otherwise, false.

備註

TryComputeLength方法會為衍生的內容類型提供計算內容長度的能力。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. 如果計算內容長度不是可能或昂貴的(需要系統緩衝處理整個內容,其中序列化會耗費大量資源,或需要系統組態大量的記憶體),這個方法會false傳回。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. 如果這個方法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.

這個方法一律會true針對ByteArrayContent傳回。This method always returned true for ByteArrayContent.

適用於