如何创建计算除法的函数

编程入门 行业动态 更新时间:2024-10-08 02:27:28
本文介绍了如何创建计算除法的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个viewmodel,我想在为Amount输入值时自动计算月度。当用户输入Amount的值时,必须将其除以12以获得Monthly.kindly帮助的获取结果。我需要一个函数来计算每月。 我尝试过:

I have a viewmodel and i want to calculate the Monthly automatically when value is entered for Amount. The moment user enters the value for Amount,it must be divided by 12 to the get results for Monthly.kindly help. I need a function to calculate the Monthly. What I have tried:

public Notch GetModel() { Notch j = new Notch(); j.Id = this.Id; j.Name = this.Name; j.Status = this.Status; j.Amount = this.Amount; j.SalaryGradeId = this.SalaryGradeId; j.Monthly = this.Monthly; return j; } public NotchViewModel() { Repository rep = new Repository(); ActiveList = Helper.GetActiveList(); SalaryGradeList = rep.GetSalaryGrades(); Id = 0; Status = 1; } public NotchViewModel(Notch j) : this() { this.Id = j.Id; this.Amount = j.Amount; this.Status = j.Status; this.Name = j.Name; this.SalaryGradeId = j.SalaryGradeId; this.Monthly = j.Monthly; }

推荐答案

如果这是C#,您可以将Amount设为属性,并让setter也设置每月值。你也可能只是每月都有一个返回Amount / 12的属性,并且没有setter。如果它是javascript,那么你需要通过函数设置它来更新这两个值。如果是打字稿,支持属性,您可以使用C#解决方案 IF this is C#, you can make Amount a property, and have the setter also set the monthly value. You could also just have monthly be a property that returns Amount/12, and doesn't have a setter. If it's javascript, then you need to have it set through a function, to update both values. If it's typescript, that supports properties and you can use the C# solution

更多推荐

如何创建计算除法的函数

本文发布于:2023-11-29 09:08:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645961.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:除法   函数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!