แก้ไข

แชร์ผ่าน


HttpRequestCachePolicy.ToString Method

Definition

Returns a string representation of this instance.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

Returns

A String value that contains the property values for this instance.

Examples

The following code example demonstrates calling this method.

static WebResponse^ GetResponseUsingDefaultCache( Uri^ uri )
{
   // Set a cache policy level for the "http:" scheme.
   HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::Default );

   // Create the request.
   WebRequest^ request = WebRequest::Create( uri );
   request->CachePolicy = policy;
   WebResponse^ response = request->GetResponse();
   Console::WriteLine( L"Policy {0}.", policy );
   Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache );
   return response;
}
public static WebResponse GetResponseUsingDefaultCache(Uri uri)
{
    // Set a cache policy level for the "http:" scheme.
    HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default);
    // Create the request.
    WebRequest request = WebRequest.Create(uri);
    request.CachePolicy = policy;
    WebResponse response = request.GetResponse();
    Console.WriteLine("Policy {0}.", policy.ToString());
    Console.WriteLine("Is the response from the cache? {0}", response.IsFromCache);
    return response;
}

Remarks

The string contains a label that identifies the property, followed by a colon (":") and the value. Properties are separated by a single space.

Applies to