CookieCollection.Item Property (Int32)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the Cookie with a specific index from a CookieCollection.

Namespace:   System.Net
Assembly:  System (in System.dll)

Public ReadOnly Property Item (
	index As Integer
) As Cookie

Parameters

index
Type: System.Int32

The zero-based index of the Cookie to be found.

Property Value

Type: System.Net.Cookie

A Cookie with a specific index from a CookieCollection.

Exception Condition
ArgumentOutOfRangeException

index is less than 0 or index is greater than or equal to Count.

You can use this to iterate over the contents of a 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

.NET Framework
Available since 1.1
Return to top
Show: