<分区>
Possible Duplicate:
Setting the default value of a DateTime Property to DateTime.Now inside the System.ComponentModel Default Value Attrbute
我正在创建一个类似日历的控件,我希望用户设置他们想要查看的年份。 但如果他们不这样做,则 SelectedYear 的属性必须是实际年份。
我试着像这样设置这个默认值:
[DefaultValue(DateTime.Today.Year)]
public int SelectedYear{
get{
return _selYear;
}
set{
_selYear = value;
UpdateCalendar();
}
}
我得到了以下错误
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type