更新时间:2023-12-02 16:10:16
您可以在 Model 中为 MonthlySalary 创建新的 readonly 属性,如下所示,并且可以在 View中访问此属性通过模型。此 readonly 属性根据 AnnualSalary 属性的值自动计算月薪。
You can create new readonly property in Model for MonthlySalary as shown below and can access this property in View through Model. This readonly property calculates Monthly Salary automatically depending upon the value of AnnualSalary property.
Public decimal MonthlySalary
{
get {
return AnnualSalary/12;
}
}
我希望这会对你有所帮助:)
I hope this will help you :)