Alexandre Queiroz - 1 month ago 7
C# Question

# What I can do to take the seconds of TimeSpan and divide by 3

``````var _delta_Timer_End = (_container_Left_Fim - _container_Left_Inicio);

decimal _time_End = Convert.ToDecimal(_delta_Timer_End);

velocity_Of_Container_End = (3 / _time_End.TotalSeconds);
``````

``````        DateTime _container_Left_Inicio = DateTime.Now;
//... Your Code that you want to measure for time
DateTime _container_Left_Fim = DateTime.Now;

TimeSpan timeDiff = _container_Left_Fim - _container_Left_Inicio;
double totalSeconds = timeDiff.TotalSeconds;
double totalSecondsDevideBy3 = totalSeconds / 3; //or 3/totalSeconds based on your need
``````

I would just do this (instead of last three lines).

``````        double totalSecondsDevideBy3 =
(_container_Left_Fim - _container_Left_Inicio).TotalSeconds / 3;
``````

Note that whenever you do any + or - operator on DateTime, it returns your TimeSpan. You can use this structure and get TotalSeconds.

I don't want to comment on your code as there are multiple mistakes.