語言

OutputCacheProfileCollection.Add(OutputCacheProfile) 方法

定義

新增一個 OutputCacheProfile 物件到集合中。

public:
 void Add(System::Web::Configuration::OutputCacheProfile ^ name);
public void Add(System.Web.Configuration.OutputCacheProfile name);
member this.Add : System.Web.Configuration.OutputCacheProfile -> unit
Public Sub Add (name As OutputCacheProfile)

參數

name
OutputCacheProfile

要加入集合的物件名稱 OutputCacheProfile 。

例外狀況

OutputCacheProfile該物件已存在於集合中,或集合是唯讀的。

範例

下列程式代碼範例示範如何使用 Add 方法。

// Execute the Add method.
System.Web.Configuration.OutputCacheProfile outputCacheProfile0 =
  new System.Web.Configuration.OutputCacheProfile("MyCacheProfile");
outputCacheProfile0.Location = 
    System.Web.UI.OutputCacheLocation.Any;
outputCacheProfile0.NoStore = false;

outputCacheProfiles.Add(outputCacheProfile0);

// Update if not locked.
if (!outputCacheSettings.IsReadOnly())
{
    webConfig.Save();
}
' Execute the Add method.
  Dim outputCacheProfile0 _
  As New System.Web.Configuration.OutputCacheProfile( _
  "MyCacheProfile")
  outputCacheProfile0.Location = _
  System.Web.UI.OutputCacheLocation.Any
  outputCacheProfile0.NoStore = _
  False

  outputCacheProfiles.Add(outputCacheProfile0)

' Update if not locked.
  If Not outputCacheSettings.IsReadOnly() Then
      webConfig.Save()
  End If

備註

該集合不能包含 OutputCacheProfile 同名的物件。

適用於

另請參閱