【发布时间】:2011-11-28 09:38:02
【问题描述】:
我开始知道 C# 3.0 带有自动实现属性的新功能,我喜欢它,因为我们不必在此声明额外的私有变量(与早期的属性相比),之前我使用的是属性即
private bool isPopup = true;
public bool IsPopup
{
get
{
return isPopup;
}
set
{
isPopup = value;
}
}
现在我已将其转换为自动实现的属性,即
public bool IsPopup
{
get; set;
}
我想将此属性的默认值设置为true,即使在page_init方法中也不使用它,我试过但没有成功,谁能解释一下如何做到这一点?
【问题讨论】:
-
在构造函数中初始化
标签: c# asp.net default-value automatic-properties