I would like to know a way to do this in C#
Let’s say I have 2 timespans : TS1 is 3h and TS2 is 12h.
What is the fastest way to calculate how many times TS1 can go within TS2?
In that case, the output would be 4.
if TS1 is 8 days and TS2 is 32 days, it would return 4 as well.
Yes, use integer division. But the devil is in the details, be sure to use an integral property of a TimeSpan to avoid overflow and round-off problems: