HttpCookie.Name 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定 Cookie 的名稱。
public:
property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String
屬性值
預設值為 null 參考 (在 Visual Basic 為 Nothing
),除非建構函式 (Constructor) 另有指定值。
範例
下列程式碼範例會從標頭中的 Cookie
用戶端接收 Cookie 集合,並迴圈查看集合中尋找具有特定名稱的 Cookie。
int loop1;
HttpCookie MyCookie;
HttpCookieCollection MyCookieCollection;
MyCookieCollection = Request.Cookies;
for (loop1 = 0; loop1 < MyCookieCollection.Count; loop1++)
{
MyCookie = MyCookieCollection[loop1];
if (MyCookie.Name == "UserName")
{
//...
}
}
Dim loop1 As Integer
Dim MyCookie As HttpCookie
Dim MyCookieCollection As HttpCookieCollection
MyCookieCollection = Request.Cookies
For loop1 = 0 TO MyCookieCollection.Count - 1
MyCookie = MyCookieCollection(loop1)
If MyCookie.Name = "UserName" Then
'...
End If
Next loop1