How can I set TotalHours to be in double format, or what I need to do to get the result in txtBoxMonatstotal as a result of 93.3.
This is my code:
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();
}
The current result looks like this:
 

Thank you for your help
You need to round the number first and then call ToString on it
txtBoxMonatstotal.Text = System.Math.Round(workedPerMonth, 1).ToString();
the second parameter in Round determines
the number of fractional digits in the return value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With