HttpCookieCollection.Item[] 屬性

定義

以指定的名稱從 Cookie 集合取得 Cookie。 這個屬性被多載,以允許用名稱或數值索引來擷取 Cookie。

多載

Item[Int32]

以指定的數值索引從 Cookie 集合取得 Cookie。

Item[String]

以指定的名稱從 Cookie 集合取得 Cookie。

Item[Int32]

以指定的數值索引從 Cookie 集合取得 Cookie。

public:
 property System::Web::HttpCookie ^ default[int] { System::Web::HttpCookie ^ get(int index); };
public System.Web.HttpCookie this[int index] { get; }
member this.Item(int) : System.Web.HttpCookie
Default Public ReadOnly Property Item(index As Integer) As HttpCookie

參數

index
Int32

要從集合中擷取的 Cookie 索引。

屬性值

HttpCookie 指定的 index

範例

下列範例會將第一個 Cookie 的名稱儲存為字串變數, (index = 0) cookie 集合中。

String CookieName = MyCookieCollection[0].Name;
Dim CookieName As String = MyCookieCollection(0).Name

另請參閱

適用於

Item[String]

以指定的名稱從 Cookie 集合取得 Cookie。

public:
 property System::Web::HttpCookie ^ default[System::String ^] { System::Web::HttpCookie ^ get(System::String ^ name); };
public System.Web.HttpCookie this[string name] { get; }
member this.Item(string) : System.Web.HttpCookie
Default Public ReadOnly Property Item(name As String) As HttpCookie

參數

name
String

要擷取的 Cookie 名稱。

屬性值

HttpCookie 指定的 name

範例

下列範例會取得名稱為 「LastVisit」 的 Cookie,並擷取其值。

String str;
 str = Request.Cookies["LastVisit"].Value;
Dim str As String
 str = Request.Cookies("LastVisit").Value

另請參閱

適用於