CookieCollection から特定の名前の Cookie を取得します。
[C#] C# では、このプロパティは CookieCollection クラスのインデクサになります。
Overloads Public Default ReadOnly Property Item( _
ByVal name As String _) As Cookie
[C#]
public Cookie this[stringname] {get;}
[C++]
public: __property Cookie* get_Item(String* name);
[JScript]
returnValue = CookieCollectionObject.Item(name);またはreturnValue = CookieCollectionObject(name);
[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。
引数 [JScript]
- name
検索する Cookie の名前。
パラメータ [Visual Basic, C#, C++]
- name
検索する Cookie の名前。
プロパティ値
CookieCollection の特定の名前の Cookie 。
例外
例外の種類 | 条件 |
---|---|
ArgumentNullException | name が null です。 |
解説
これを使用して、 CookieCollection の内容を反復できます。
使用例
' Get the cookies in the 'CookieCollection' object using the 'Item' property.
Try
If cookies.Count = 0 Then
Console.WriteLine("No cookies to display")
Return
End If
Console.WriteLine("{0}", cookies("UserName").ToString())
Console.WriteLine("{0}", cookies("DateOfBirth").ToString())
Console.WriteLine("{0}", cookies("PlaceOfBirth").ToString())
Console.WriteLine("")
Catch e As Exception
Console.WriteLine(("Exception raised." + ControlChars.Cr + "Error : " + e.Message))
End Try
[C#]
// Get the cookies in the 'CookieCollection' object using the 'Item' property.
// The 'Item' property in C# is implemented through Indexers.
// The class that implements indexers is usually a collection of other objects.
// This class provides access to those objects with the '<class-instance>[i]' syntax.
try {
if(cookies.Count == 0) {
Console.WriteLine("No cookies to display");
return;
}
Console.WriteLine("{0}", cookies["UserName"].ToString());
Console.WriteLine("{0}", cookies["DateOfBirth"].ToString());
Console.WriteLine("{0}", cookies["PlaceOfBirth"].ToString());
Console.WriteLine("");
}
catch(Exception e) {
Console.WriteLine("Exception raised.\nError : " + e.Message);
}
[C++]
// Get the cookies in the 'CookieCollection' object using the 'Item' property.
try {
if(cookies->Count == 0) {
Console::WriteLine(S"No cookies to display");
return;
}
Console::WriteLine(S"{0}", cookies->Item[S"UserName"]);
Console::WriteLine(S"{0}", cookies->Item[S"DateOfBirth"]);
Console::WriteLine(S"{0}", cookies->Item[S"PlaceOfBirth"]);
Console::WriteLine(S"");
}
catch(Exception* e) {
Console::WriteLine(S"Exception raised.\nError : {0}", e->Message);
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
CookieCollection クラス | CookieCollection メンバ | System.Net 名前空間 | CookieCollection.Item オーバーロードの一覧 | CookieCollection | CookieContainer | CookieException