So:
public TimeSpan TempoOtimista { get; set; }
public TimeSpan TempoProvavel { get; set; }
public TimeSpan TempoPessimista { get; set; }
public TimeSpan TempoRevisado { get; set; }
TempoRevisado = new TimeSpan(0, 0,
(int)(TempoOtimista + TempoProvavel + TempoPessimista).TotalSeconds / 3);
See running on dotNetFiddle .
You can say that I changed the type. But now it's all right. DateTime
marks a point in time, does not mark a time spent. This is completely wrong. With wrong data, you can only get wrong results. So the first thing to fix is to change the type to save a time interval with TimeSpan
.
We can only do the right thing. You'd even have to make the account using the wrong way, but when you conceptualize wrong, sooner or later you'll have problems.
At some point I had to get the amount of seconds because TimeSpan
does not allow division.