HttpCookieCollection.Item[] 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 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 的名称存储为字符串变量, (索引 = 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