ProfilePropertySettings.DefaultValue 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置动态生成的 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 序列化)或 base-64 编码的二进制字符串(如果属性的序列化模式为二进制序列化)。