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 的索引。

属性值

指定 HttpCookieindex

示例

以下示例将第一个 Cookie 的名称存储为 cookie 集合中的字符串变量(index = 0)。

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 的名称。

属性值

指定 HttpCookiename

示例

以下示例获取名为“LastVisit”的 Cookie 并提取其值。

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

另请参阅

适用于