C#,将时间从浮点数表示转换为字符串表示

Але*_* Д. 4 c# algorithm

我将时间表示为浮点数(以秒为单位).我需要一个函数将此表示转换为字符串格式.像这样的东西:

    /// <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)
    }
Run Code Online (Sandbox Code Playgroud)

例如,10.0转换为00:00:10,67.0转换为00:01:07

Ant*_*lev 9

那将是TimeSpan.FromSeconds:

返回TimeSpan表示指定秒数的值,其中规范精确到最接近的毫秒.