locked
how does can be convert into two decimal places RRS feed

  • Question

  • User-1355965324 posted

    I have the following code an I want to convert it into two decimal places like  Please help

    SalaryPerHour = 20000.0000

    SalaryPerMonth= 1000.0000

    I want to convert it as 20000.00 and 1000.00

    HourlySalary = Convert.ToDecimal(row["SalaryPerHour"].ToString()),
    MonthlySalary = Convert.ToDecimal(row["SalaryPerMonth"].ToString()),
    YearlySalary = Convert.ToDecimal(row["SalaryPerYear"].ToString()),

    Tuesday, January 29, 2019 9:01 AM

Answers

  • User-1355965324 posted

    I corrected  using Math.Round

    HourlySalary = Math.Round(Convert.ToDecimal(row["SalaryPerHour"].ToString()),2)

    Thanks

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 29, 2019 11:41 AM

All replies