CookieCollection.Item[] 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 Cookie 中获取特定的 CookieCollection。
重载
Item[Int32] |
从 Cookie 中获取具有特定索引的 CookieCollection。 |
Item[String] |
从 Cookie 中获取具有特定名称的 CookieCollection。 |
Item[Int32]
- Source:
- CookieCollection.cs
- Source:
- CookieCollection.cs
- Source:
- CookieCollection.cs
从 Cookie 中获取具有特定索引的 CookieCollection。
public:
property System::Net::Cookie ^ default[int] { System::Net::Cookie ^ get(int index); };
public System.Net.Cookie this[int index] { get; }
member this.Item(int) : System.Net.Cookie
Default Public ReadOnly Property Item(index As Integer) As Cookie
参数
属性值
Cookie 中具有特定索引的 CookieCollection。
例外
index
小于 0 或 index
大于等于 Count。
示例
// 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 ] );
Console::WriteLine( "" );
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception raised.\nError : {0}", e->Message );
}
// 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);
}
'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
注解
可以使用它来循环访问 的内容 CookieCollection。
另请参阅
适用于
Item[String]
- Source:
- CookieCollection.cs
- Source:
- CookieCollection.cs
- Source:
- CookieCollection.cs
从 Cookie 中获取具有特定名称的 CookieCollection。
public:
property System::Net::Cookie ^ default[System::String ^] { System::Net::Cookie ^ get(System::String ^ name); };
public System.Net.Cookie this[string name] { get; }
public System.Net.Cookie? this[string name] { get; }
member this.Item(string) : System.Net.Cookie
Default Public ReadOnly Property Item(name As String) As Cookie
参数
属性值
Cookie 中具有特定名称的 CookieCollection。
例外
name
为 null
。
示例
// 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" ] );
Console::WriteLine( "{0}", cookies[ "DateOfBirth" ] );
Console::WriteLine( "{0}", cookies[ "PlaceOfBirth" ] );
Console::WriteLine( "" );
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception raised.\nError : {0}", e->Message );
}
// 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);
}
' 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
注解
可以使用它来循环访问 的内容 CookieCollection。