I have a code generating a timespan to calculate a duration of some action. What I want to do is to take that result (the duration) and divide it by a number, any number.
How can I do that?
A TimeSpan value represents a time interval and can be expressed as a particular number of days, hours, minutes, seconds, and milliseconds.
TimeSpan (amount of time) is a new data type that can be used to store information about an elapsed time period or a time span. For example, the value in the picture (148:05:36.254) consists of 148 hours, 5 minutes, 36 seconds, and 254 milliseconds.
Add() Method in C# This method is used to a get new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance. Syntax public TimeSpan Add (TimeSpan t);
You can use ticks of the original timespan:
var res = new TimeSpan(origSpan.Ticks / aNumberAnyNumber);
try
TimeSpan X = ...; var Result = X.TotalMilliseconds / WhatEverNumber;
For reference see MSDN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With