CookieCollection から特定のインデックスを持つ Cookie を取得します。
[C#] C# では、このプロパティは CookieCollection クラスのインデクサになります。
Overloads Public Default ReadOnly Property Item( _
ByVal index As Integer _) As Cookie
[C#]
public Cookie this[intindex] {get;}
[C++]
public: __property Cookie* get_Item(intindex);
[JScript]
returnValue = CookieCollectionObject.Item(index);またはreturnValue = CookieCollectionObject(index);
[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。
引数 [JScript]
- index
検索する Cookie の 0 から始まるインデックス番号。
パラメータ [Visual Basic, C#, C++]
- index
検索する Cookie の 0 から始まるインデックス番号。
プロパティ値
CookieCollection の特定のインデックスを持つ Cookie 。
例外
例外の種類 | 条件 |
---|---|
ArgumentOutOfRangeException | index < 0 or index >= Count |
解説
これを使用して、 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
Dim j As Integer
For j = 0 To cookies.Count - 1
Console.WriteLine("{0}", cookies(j).ToString())
Next j
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;
}
for(int j = 0; j < cookies.Count; j++)
Console.WriteLine("{0}", cookies[j].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;
}
for(int j = 0; j < cookies->Count; j++)
Console::WriteLine(S"{0}", cookies->Item[j]);
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