HttpCookieCollection.GetKey(Int32) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 숫자 인덱스에서 쿠키의 키(이름)를 반환합니다.
public:
System::String ^ GetKey(int index);
public string GetKey(int index);
member this.GetKey : int -> string
Public Function GetKey (index As Integer) As String
매개 변수
- index
- Int32
컬렉션에서 검색할 키의 인덱스입니다.
반품
로 지정된 index쿠키의 이름입니다.
예제
다음 예제에서는 쿠키 컬렉션에서 각 쿠키를 반환하고 이름이 "LastVisit"인지 확인하고, "LastVisit"이 발견되면 해당 값을 현재 날짜 및 시간으로 업데이트합니다.
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