I have a time represented as a floating-point number (in seconds). I need a function to convert this representation to string format. Somethins like this:
    /// <summary>
    /// Get time from a float representation.
    /// </summary>
    /// <param name="f">Time in a floating-point number.</param>
    /// <returns>Time in a string format.</returns>
    string GetTime(float f)
    {
        return f.ToString(); // string format is hh:mm:ss (h-hours, m-minutes, s-seconds)
    }
For example, 10.0 converts to 00:00:10, 67.0 converts to 00:01:07
That will be TimeSpan.FromSeconds:
Returns a
TimeSpanthat represents a specified number of seconds, where the specification is accurate to the nearest millisecond.
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