語言

ProfilePropertySettings.DefaultValue 屬性

定義

取得或設定動態產生 ProfileCommon 類別中相關屬性的預設值。

public:
 property System::String ^ DefaultValue { System::String ^ get(); void set(System::String ^ value); };
[System.Configuration.ConfigurationProperty("defaultValue", DefaultValue="")]
public string DefaultValue { get; set; }
[<System.Configuration.ConfigurationProperty("defaultValue", DefaultValue="")>]
member this.DefaultValue : string with get, set
Public Property DefaultValue As String

屬性值

包含動態產生 ProfileCommon 類別中相關屬性預設值的字串。 預設為空字串(“”)。

屬性

範例

以下程式碼範例說明如何使用該 DefaultValue 屬性。 此程式碼範例是本類別更大範例 ProfileSection 的一部分。

// Get the current DefaultValue property value.
Console.WriteLine(
    "Current DefaultValue value: '{0}'", profilePropertySettings.DefaultValue);

// Set the DefaultValue property to "March 16, 2004".
profilePropertySettings.DefaultValue = "March 16, 2004";
' Get the current DefaultValue property value.
Console.WriteLine( _
    "Current DefaultValue value: '{0}'", profilePropertySettings.DefaultValue)

' Set the DefaultValue property to "March 16, 2004".
profilePropertySettings.DefaultValue = "March 16, 2004"

備註

執行時,ASP.NET 編譯系統會根據設定檔區段中指定的 profile 資訊產生一個稱為 ProfileCommon的類別,該類別由 衍生而 ProfileBase來。 這個類別允許你存取並修改個別使用者設定檔的數值。

ProfileCommon類別定義基於設定檔該properties節子節中定義profile的屬性。 你為類別實例 ProfilePropertySettings 指定的屬性值,將用來定義類別中 ProfileCommon 相關的屬性。

當個別使用者設定檔中沒有該屬性的值時,預設值會用作相關 ProfileCommon 類別屬性的初始值。 屬性 DefaultValue 可以是字串值、XML 編碼值(該屬性的序列化模式為 XML 序列化)或是基數 64 編碼的二進位字串(若該屬性的序列化模式為二進位序列化)。

適用於

另請參閱