HttpConnectionOptionHeaderValueCollection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示 HTTP 要求上 連線 HTTP 標頭的值。
public ref class HttpConnectionOptionHeaderValueCollection sealed : IIterable<HttpConnectionOptionHeaderValue ^>, IVector<HttpConnectionOptionHeaderValue ^>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpConnectionOptionHeaderValueCollection final : IIterable<HttpConnectionOptionHeaderValue>, IVector<HttpConnectionOptionHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpConnectionOptionHeaderValueCollection final : IIterable<HttpConnectionOptionHeaderValue>, IVector<HttpConnectionOptionHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpConnectionOptionHeaderValueCollection : IEnumerable<HttpConnectionOptionHeaderValue>, IList<HttpConnectionOptionHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpConnectionOptionHeaderValueCollection : IEnumerable<HttpConnectionOptionHeaderValue>, IList<HttpConnectionOptionHeaderValue>, IStringable
Public NotInheritable Class HttpConnectionOptionHeaderValueCollection
Implements IEnumerable(Of HttpConnectionOptionHeaderValue), IList(Of HttpConnectionOptionHeaderValue), IStringable
- 繼承
- 屬性
- 實作
Windows 需求
裝置系列 |
Windows 10 (已於 10.0.10240.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
|
範例
下列範例程式碼示範使用 HttpConnectionOptionValueCollection 和HttpConnectionOptionHeaderValueCollection 和 HttpConnectionOptionHeaderValue類別的屬性和方法,取得及設定HttpRequestMessage物件上的Connection HTTP 標頭的方法。
using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;
public void DemonstrateHeaderRequestConnection() {
var request = new HttpRequestMessage();
bool parsedOk = false;
// Set the header with a string.
parsedOk = request.Headers.Connection.TryParseAdd("close");
// Set the header with a strong type.
request.Headers.Connection.Add(new HttpConnectionOptionHeaderValue("cache-control"));
// Get the strong type out
foreach (var value in request.Headers.Connection) {
System.Diagnostics.Debug.WriteLine("One of the Connection values: {0}", value.Token);
}
// The ToString() is useful for diagnostics, too.
System.Diagnostics.Debug.WriteLine("The Connection ToString() results: {0}", request.Headers.Connection.ToString());
}
備註
HttpConnectionOptionHeaderValueCollection 代表 HTTP 要求上 連線 HTTP 標頭的值。
HttpConnectionOptionHeaderValueCollection 是 HttpConnectionOptionHeaderValue 物件的集合,用於 HTTP 連接 標頭上的連接資訊。
HttpRequestHeaderCollection上的Connection屬性會傳回 HttpConnectionOptionHeaderValueCollection 物件。
集合成員清單
針對 JavaScript,HttpConnectionOptionHeaderValueCollection 具有成員清單中顯示的成員。 此外,HttpConnectionOptionHeaderValueCollection 支援 Array.prototype 的成員,並使用索引來存取專案。
列舉 C# 或 Microsoft Visual Basic 中的集合
您可以在 C# 或 Microsoft Visual Basic 中逐一查看 HttpConnectionOptionHeaderValueCollection 物件。 在許多情況下,例如使用 foreach 語法,編譯器會為您執行此轉換,而且您不需要明確地轉換成 IEnumerable<HttpConnectionOptionHeaderValue>
。 如果您需要明確轉換,例如,如果您想要呼叫GetEnumerator,請使用HttpConnectionOptionHeaderValue條件約束將集合物件轉換成IEnumerable < T >。
屬性
Size |
取得集合中的 HttpConnectionOptionHeaderValue 物件數目。 |