Share via


HttpCookieCollection.Item[] プロパティ

定義

指定した名前のクッキーをクッキー コレクションから取得します。 このプロパティは、名前インデックスと数値インデックスのいずれかでクッキーを取得できるようにするためにオーバーロードされます。

オーバーロード

Item[Int32]

指定された数値インデックスを持つクッキーをクッキー コレクションから取得します。

Item[String]

指定した名前のクッキーをクッキー コレクションから取得します。

Item[Int32]

指定された数値インデックスを持つクッキーをクッキー コレクションから取得します。

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

コレクションから取得するクッキーのインデックス。

プロパティ値

HttpCookie で指定された index

次の例では、最初の Cookie の名前を文字列変数 (index = 0) として Cookie コレクションに格納します。

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

こちらもご覧ください

適用対象

Item[String]

指定した名前のクッキーをクッキー コレクションから取得します。

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

取得するクッキーの名前。

プロパティ値

HttpCookie で指定された name

次の例では、"LastVisit" という名前の Cookie を取得し、その値を抽出します。

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

こちらもご覧ください

適用対象