Aracılığıyla paylaş


HttpCookieCollection.GetKey(Int32) Yöntem

Tanım

Belirtilen sayısal dizindeki tanımlama bilgisinin anahtarını (adını) döndürür.

public:
 System::String ^ GetKey(int index);
public string GetKey (int index);
member this.GetKey : int -> string
Public Function GetKey (index As Integer) As String

Parametreler

index
Int32

Koleksiyondan alınacak anahtarın dizini.

Döndürülenler

String

tarafından indexbelirtilen tanımlama bilgisinin adı.

Örnekler

Aşağıdaki örnek tanımlama bilgisi koleksiyonundaki her tanımlama bilgisini döndürür, "LastVisit" olarak adlandırılıp adlandırılmadığını denetler ve "LastVisit" bulunursa değerini geçerli tarih ve saate güncelleştirir.

int loop1;

 HttpCookieCollection MyCookieCollection = Response.Cookies;

 for(loop1 = 0; loop1 < MyCookieCollection.Count; loop1++)
 {
    if(MyCookieCollection.GetKey(loop1) == "LastVisit")
    {
       MyCookieCollection[loop1].Value = DateTime.Now.ToString();
       MyCookieCollection.Set(MyCookieCollection[loop1]);
    }
 }
Dim loop1 As Integer
 Dim MyCookie As HttpCookie
 Dim MyCookieCollection As HttpCookieCollection = Request.Cookies
 
 For loop1 = 0 To MyCookieCollection.Count - 1
    If MyCookieCollection.GetKey(loop1) = "LastVisit" Then
       MyCookieCollection(loop1).Value = DateTime.Now().ToString()
       MyCookieCollection.Set(MyCookieCollection(loop1))
       Exit For
    End If
 Next loop1

Şunlara uygulanır