且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在mvc索引页面中将年薪转换为月薪?

更新时间: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 :)