我有一个DateTimePicker
名为dtProcurationDate
,它将日期显示为自定义格式yyyy/M/d
..现在我只想用代码获取它的年份
string year = dtProcurationDate.Value.Year.ToString();
也尝试了
this.dtProcurationDate.CustomFormat = "yyyy";
string year = dtProcurationDate.Value.Year.ToString();
但它给了我一个空值..
答案 0 :(得分:1)
//syntax is datetimepicker.Value.Year
int year = dtProcurationDate.Value.Year; //your case