I have the following function that typically need to return a value. I calculate the value in a calculator app and I get values just fine. But in the program below the value variable value is always 0. I have tried using long, double, float but nothing works. Please help.
public string CalculateElapsedPercent(DateTime endTime, DateTime startTime)
{
string result = string.Empty;
DateTime currentTime = DateTime.Now;
if (currentTime > endTime)
{
result = " (100 %)";
return result;
}
long nr = (currentTime - startTime).Ticks;
long dr = (endTime - startTime).Ticks;
double value = (nr / dr) * 100.0;
result = " (" + value.ToString() + " %)";
return result;
}