Share via


HttpRequestCachePolicy.ToString 方法

定義

傳回這個執行個體的字串表示。

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

傳回

String 值,包含這個執行個體的屬性值。

範例

下列程式代碼範例示範如何呼叫這個方法。

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;
}

備註

字串包含可識別屬性的標籤,後面接著冒號 (“:”) 和值。 屬性會以單一空格分隔。

適用於