共用方式為


HttpLanguageRangeWithQualityHeaderValueCollection 類別

定義

表示 HTTP 要求上 Accept-Language HTTP 標頭的值。

public ref class HttpLanguageRangeWithQualityHeaderValueCollection sealed : IIterable<HttpLanguageRangeWithQualityHeaderValue ^>, IVector<HttpLanguageRangeWithQualityHeaderValue ^>, 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 HttpLanguageRangeWithQualityHeaderValueCollection final : IIterable<HttpLanguageRangeWithQualityHeaderValue>, IVector<HttpLanguageRangeWithQualityHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpLanguageRangeWithQualityHeaderValueCollection final : IIterable<HttpLanguageRangeWithQualityHeaderValue>, IVector<HttpLanguageRangeWithQualityHeaderValue>, 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 HttpLanguageRangeWithQualityHeaderValueCollection : IEnumerable<HttpLanguageRangeWithQualityHeaderValue>, IList<HttpLanguageRangeWithQualityHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpLanguageRangeWithQualityHeaderValueCollection : IEnumerable<HttpLanguageRangeWithQualityHeaderValue>, IList<HttpLanguageRangeWithQualityHeaderValue>, IStringable
Public NotInheritable Class HttpLanguageRangeWithQualityHeaderValueCollection
Implements IEnumerable(Of HttpLanguageRangeWithQualityHeaderValue), IList(Of HttpLanguageRangeWithQualityHeaderValue), IStringable
繼承
Object Platform::Object IInspectable HttpLanguageRangeWithQualityHeaderValueCollection
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列範例程式碼示範方法,使用 HttpLanguageRangeWithQualityHeaderValueCollection 和HttpLanguageRangeWithQualityHeaderValueCollection 和 HttpLanguageRangeWithQualityHeaderValue類別上的屬性和方法,在HttpRequestMessage物件上取得和設定Accept-Language HTTP 標頭。

using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderRequestAcceptLanguage() {
            var request = new HttpRequestMessage();
            bool parsedOk = false;

            // Set the header with a string.
            parsedOk = request.Headers.AcceptLanguage.TryParseAdd("da");
            parsedOk = request.Headers.AcceptLanguage.TryParseAdd("en-gb;q=0.8");

            // Set the header with a strong type.
            request.Headers.AcceptLanguage.Add(new HttpLanguageRangeWithQualityHeaderValue("en", .7));

            // Get the strong type out
            foreach (var value in request.Headers.AcceptLanguage) {
                System.Diagnostics.Debug.WriteLine("One of the AcceptLanguage values: {0}={1}", value.LanguageRange, value.Quality);
            }

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The AcceptLanguage ToString() results: {0}", request.Headers.AcceptLanguage.ToString());
        }

備註

HttpLanguageRangeWithQualityHeaderValueCollection 類別代表 HTTP 要求上 Accept-Language HTTP 標頭的值。

HttpLanguageRangeWithQualityHeaderValueCollection 提供 HttpLanguageRangeWithQualityHeaderValue 類別的集合容器,用於 接受 Accept-Language HTTP 標頭中的語言資訊。

HttpRequestHeaderCollection上的AcceptLanguage屬性會傳回 HttpLanguageRangeWithQualityHeaderValueCollection 物件。

屬性

Size

取得集合中的 HttpLanguageRangeWithQualityHeaderValue 物件數目。

方法

Append(HttpLanguageRangeWithQualityHeaderValue)

將新的 HttpLanguageRangeWithQualityHeaderValue 專案新增至集合結尾。

Clear()

從集合中移除所有物件。

First()

擷取反覆運算器至集合中的第一個 HttpLanguageRangeWithQualityHeaderValue 專案。

GetAt(UInt32)

會傳回集合中指定索引處的 HttpLanguageRangeWithQualityHeaderValue

GetMany(UInt32, HttpLanguageRangeWithQualityHeaderValue[])

擷取從集合中指定索引開始的 HttpLanguageRangeWithQualityHeaderValue 專案。

GetView()

會傳回 HttpLanguageRangeWithQualityHeaderValueCollection的不可變檢視。

IndexOf(HttpLanguageRangeWithQualityHeaderValue, UInt32)

擷取集合中 HttpLanguageRangeWithQualityHeaderValue 的索引。

InsertAt(UInt32, HttpLanguageRangeWithQualityHeaderValue)

HttpLanguageRangeWithQualityHeaderValue 插入集合中指定的索引處。

ParseAdd(String)

剖析並將專案新增至 HttpLanguageRangeWithQualityHeaderValueCollection

RemoveAt(UInt32)

HttpLanguageRangeWithQualityHeaderValueCollection中移除位於指定索引處的專案。

RemoveAtEnd()

從集合中移除最後一個 HttpLanguageRangeWithQualityHeaderValue 專案。

ReplaceAll(HttpLanguageRangeWithQualityHeaderValue[])

以指定的HttpLanguageRangeRangeWithQualityHeaderValue 專案取代集合中的所有 HttpLanguageRangeWithQualityHeaderValue專案。

SetAt(UInt32, HttpLanguageRangeWithQualityHeaderValue)

設定集合中指定索引處的 HttpLanguageRangeWithQualityHeaderValue

ToString()

會傳回字串,表示目前的 HttpLanguageRangeWithQualityHeaderValueCollection 物件。

TryParseAdd(String)

嘗試剖析並將指定的專案新增至 HttpLanguageRangeWithQualityHeaderValueCollection

適用於

另請參閱