gpt4 book ai didi

c# - 准时双排版

转载 作者:行者123 更新时间:2023-12-04 21:32:11 25 4
gpt4 key购买 nike

如何设置TotalHours是双格式,或者我需要做什么才能得到 txtBoxMonatstotal 中的结果由于93.3 .
这是我的代码:

private void calendar1_MonthChanged(object sender, EventArgs e)
{
DateTime start = new DateTime(calendar1.CurrentDate.Year, calendar1.CurrentDate.Month, 1);
DateTime stop = new DateTime(calendar1.CurrentDate.Year, calendar1.CurrentDate.Month, 1).AddMonths(1).AddDays(-1);
int numberOfWorkDays = GetNumberOfWorkingDays(start, stop);

double shouldWorkPerMonth = tag_durschnit * numberOfWorkDays;
double workedPerMonth = workingHours.Where(x => x.Key.Date.Year == start.Year && x.Key.Month == start.Month).Sum(x => x.Value.TotalHours);
double saldo = workedPerMonth - shouldWorkPerMonth;

txtBoxMonatstotal.Text = workedPerMonth.ToString();
txtBoxSollzeit.Text = shouldWorkPerMonth.ToString();
txtBoxSaldo.Text = saldo.ToString();

}

当前结果如下所示:

txtBoxMonatstotal

感谢您的帮助

最佳答案

您需要 round先打号码再调用ToString在上面

txtBoxMonatstotal.Text = System.Math.Round(workedPerMonth, 1).ToString();
Round 中的第二个参数决定

the number of fractional digits in the return value.

关于c# - 准时双排版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48377827/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com