System.Net.WebHeaderCollection.GetValues Method

Gets an array of header values stored in a header.

Syntax

public override string[] GetValues (string header)

Parameters

header
The header to return.

Returns

An array of header strings.

Remarks

WebHeaderCollection.GetValues(string) returns the contents of the specified header as an array.

Example

This example demonstrates the WebHeaderCollection.GetValues(string) method.

C# Example

using System;
using System.Net;

class GetValuesExample
{
   public static void Main()
   {
      Uri contosoUri = new Uri("http://www.contoso.com");
      HttpWebRequest httpContoso = 
         (HttpWebRequest)WebRequest.Create(contosoUri);

      httpContoso.SendChunked=true;
      httpContoso.TransferEncoding="compress";
      httpContoso.TransferEncoding="gzip";
    
      WebHeaderCollection webColl = httpContoso.Headers;
      String[] sAry = webColl.GetValues("Transfer-Encoding");

      Console.WriteLine("Transfer-Encoding:");
      foreach(string s in sAry)
         Console.WriteLine("{0}", s);
   }
}

The output is

Transfer-Encoding:

compress

gzip

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0