locked
help. c# asp.net computation RRS feed

  • Question

  • User1046245955 posted

    i have this computation:

    double totalholidays = Convert.ToDouble(Session["toteiddays"].ToString()); 

    lblleavedays.Text = Convert.ToString(GetWorkingDays(dtfrom, dtto) - totalholidays); 

    but the problem is some of the answer got an (-) i want to remove the (-) in the total lblleavedays.text

    Wednesday, September 26, 2018 6:19 AM

All replies

  • User-369506445 posted

    hi

    you can use below sample

     var num = -10;
     var myInt = num * -1;

    and your sample 

               double totalholidays = Convert.ToDouble(Session["toteiddays"].ToString());
                var result = GetWorkingDays(dtfrom, dtto) - totalholidays;
                if (result < 0)
                    result = result * -1;
                lblleavedays.Text = result.ToString();

    Wednesday, September 26, 2018 6:28 AM
  • User-183374066 posted

    but the problem is some of the answer got an (-) i want to remove the (-) in the total lblleavedays.text

    You String Replace Function

    lblleavedays.Text = Convert.ToString(GetWorkingDays(dtfrom, dtto) - totalholidays).Replace('-',''); 

    You can replace either character or string. For string use double quotes 

    "-123".Replace("-"," ")

    Regards

    Wednesday, September 26, 2018 8:05 AM