更新时间:2023-12-01 20:40:22
您也可以使用DateTime.AddDays()
方法将NextDay
作为DateTime
传递给Model
.
此方法返回一个新的DateTime
,该DateTime
将指定的天数添加到该实例的值中.
You can pass the NextDay
as a DateTime
in the Model
as well using DateTime.AddDays()
method.
This method returns a new DateTime
that adds the specified number of days to the value of this instance.
model.NextDay = startDate.AddDays(1);
然后在DisplayNameFor
中使用该属性:
<a href="@Html.DisplayNameFor(model => model.NextDay)">Next Day</a>
在MSDN
此方法不会更改此DateTime的值.而是返回一个新的DateTime,其值是此操作的结果.
This method does not change the value of this DateTime. Instead, it returns a new DateTime whose value is the result of this operation.