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

注解

字符串包含标识属性的标签,后跟冒号 (“:”) 和值。 属性由单个空格分隔。

适用于