在十进制以及int的代码行中均出现错误 [英] getting an error for line of code both for decimal as well as int
问题描述
嘿,我有以下代码
hey I have following code
return string.Format("{0} (${1} EE ${2} DEP to Any Plan)",
_excelResource.GetValue("EMPLOYERCOST", languageId),
_excelService.CheckNull(bundle, m => m.EmployerContribution.ContributionAmount.Amount.Employee),
_excelService.CheckNull(bundle, m => m.EmployerContribution.ContributionAmount.Amount.Dependent));
从gui插入金额为100
它应该显示100,当插入金额150.75时应该显示150.75.
上面的代码我得到结果100.00和150.75
如果我应用math.round,那么也没有效果,甚至不能转换为十进制
.....应该有什么代码,以便在不同的情况下我得到的结果与插入到gui中的结果相同.
金额仅供计算.
from gui when amount insert is 100
it should display 100 and when amount insert 150.75 it should display 150.75.
with above code i am getting result 100.00 and 150.75
if i apply math.round then also no effect and not even convert.to decimal
.....what code should be there so that in different scenario i get the same result as inserted in gui.
amount are for calculation purpose.
help will be highly appreciable
推荐答案
{1} EE
{2}到任何计划的DEP)" , _excelResource.GetValue(" ,languageId), _excelService.CheckNull(bundle,m = > m.EmployerContribution.ContributionAmount.Amount.Employee), _excelService.CheckNull(bundle,m = > m.EmployerContribution.ContributionAmount.Amount.Dependent));
{2} DEP to Any Plan)", _excelResource.GetValue("EMPLOYERCOST", languageId), _excelService.CheckNull(bundle, m => m.EmployerContribution.ContributionAmount.Amount.Employee), _excelService.CheckNull(bundle, m => m.EmployerContribution.ContributionAmount.Amount.Dependent));
从gui中插入金额为100
它应该显示100,当插入金额150.75时应该显示150.75.
上面的代码我得到结果100.00和150.75
如果我应用math.round,那么也没有效果,甚至不能转换为十进制
.....应该有什么代码,以便在不同的情况下我得到的结果与插入到gui中的结果相同.
金额仅供计算.
帮助非常重要
from gui when amount insert is 100
it should display 100 and when amount insert 150.75 it should display 150.75.
with above code i am getting result 100.00 and 150.75
if i apply math.round then also no effect and not even convert.to decimal
.....what code should be there so that in different scenario i get the same result as inserted in gui.
amount are for calculation purpose.
help will be highly appreciable
尝试一下..
Try This..
decimal result = _excelService.CheckNull(bundle, m => m.EmployerContribution.ContributionAmount.Amount.Employee);
string displayResult = result.ToString("0.##");
如果它对您有用,则接受它.
if it will work for you then accept it.
这篇关于在十进制以及int的代码行中均出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!