WebHeaderCollection.GetValues 메서드

정의

헤더에 저장된 헤더 값의 배열을 가져옵니다.

오버로드

GetValues(String)

헤더에 저장된 헤더 값의 배열을 가져옵니다.

GetValues(Int32)

헤더 컬렉션의 index 위치에 저장된 헤더 값의 배열을 가져옵니다.

GetValues(String)

Source:
WebHeaderCollection.cs
Source:
WebHeaderCollection.cs
Source:
WebHeaderCollection.cs

헤더에 저장된 헤더 값의 배열을 가져옵니다.

public:
 override cli::array <System::String ^> ^ GetValues(System::String ^ header);
public override string[]? GetValues (string header);
public override string[] GetValues (string header);
override this.GetValues : string -> string[]
Public Overrides Function GetValues (header As String) As String()

매개 변수

header
String

반환할 헤더입니다.

반환

String[]

헤더 문자열의 배열입니다.

예제

다음 예제에서는 메서드를 GetValues 사용하여 의 각 헤더에 대한 값 배열을 검색합니다 WebHeaderCollection.

// Create a web request for S"www.msn.com".
HttpWebRequest^ myHttpWebRequest = dynamic_cast<HttpWebRequest^>(WebRequest::Create( "http://www.msn.com" ));
myHttpWebRequest->Timeout = 1000;

// Get the associated response for the above request.
HttpWebResponse^ myHttpWebResponse = dynamic_cast<HttpWebResponse^>(myHttpWebRequest->GetResponse());

// Get the headers associated with the response.
WebHeaderCollection^ myWebHeaderCollection = myHttpWebResponse->Headers;
for ( int i = 0; i < myWebHeaderCollection->Count; i++ )
{
   String^ header = myWebHeaderCollection->GetKey( i );
   array<String^>^values = myWebHeaderCollection->GetValues( header );
   if ( values->Length > 0 )
   {
      Console::WriteLine( "The values of {0} header are : ", header );
      for ( int j = 0; j < values->Length; j++ )
         Console::WriteLine( "\t {0}", values[ j ] );
   }
   else
            Console::WriteLine( "There is no value associated with the header" );
}
myHttpWebResponse->Close();
// Create a web request for "www.msn.com".
 HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create("http://www.msn.com");
myHttpWebRequest.Timeout = 1000;
// Get the associated response for the above request.
 HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse();

// Get the headers associated with the response.
WebHeaderCollection myWebHeaderCollection = myHttpWebResponse.Headers;

for(int i = 0; i < myWebHeaderCollection.Count; i++) {
    String header = myWebHeaderCollection.GetKey(i);
    String[] values = myWebHeaderCollection.GetValues(header);
    if(values.Length > 0) {
        Console.WriteLine("The values of {0} header are : ", header);
        for(int j = 0; j < values.Length; j++) 
            Console.WriteLine("\t{0}", values[j]);
    }
    else
    {
        Console.WriteLine("There is no value associated with the header");
    }
}
myHttpWebResponse.Close();
    'Create a web request for "www.msn.com".
    Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.msn.com"), HttpWebRequest)
myHttpWebRequest.Timeout = 1000
    'Get the associated response for the above request.
    Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
    
    'Get the headers associated with the response.
    Dim myWebHeaderCollection As WebHeaderCollection = myHttpWebResponse.Headers
    Dim i As Integer
    For i = 0 To myWebHeaderCollection.Count - 1
        Dim header As [String] = myWebHeaderCollection.GetKey(i)
        Dim values As [String]() = myWebHeaderCollection.GetValues(header)
        If values.Length > 0 Then
            Console.WriteLine("The values of {0} header are : ", header)
            Dim j As Integer
            For j = 0 To values.Length - 1
                Console.WriteLine(ControlChars.Tab + "{0}", values(j))
            Next j
        Else
            Console.WriteLine("There is no value associated with the header")
        End If
    Next i

설명

GetValues 는 지정된 헤더의 내용을 배열로 반환합니다.

적용 대상

GetValues(Int32)

Source:
WebHeaderCollection.cs
Source:
WebHeaderCollection.cs
Source:
WebHeaderCollection.cs

헤더 컬렉션의 index 위치에 저장된 헤더 값의 배열을 가져옵니다.

public:
 override cli::array <System::String ^> ^ GetValues(int index);
public override string[]? GetValues (int index);
public override string[] GetValues (int index);
override this.GetValues : int -> string[]
Public Overrides Function GetValues (index As Integer) As String()

매개 변수

index
Int32

반환할 헤더 인덱스입니다.

반환

String[]

헤더 문자열의 배열입니다.

설명

GetValues 는 지정된 헤더의 내용을 배열로 반환합니다.

적용 대상