語言

HttpCookieCollection.Item[] 屬性

定義

從 cookie 集合中取得指定名稱的 cookie。 此特性被過度載重,允許以名稱或數字索引檢索 Cookie。

多載

名稱 Description
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 索引。

屬性值

由 HttpCookieindex指定 。

範例

以下範例將第一個 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

要取回的餅乾名稱。

屬性值

由 HttpCookiename指定 。

範例

以下範例取得名為「LastVisit」的 cookie,並提取其值。

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

另請參閱

適用於