我将时间表示为浮点数(以秒为单位)。我需要一个函数将此表示转换为字符串格式。有些人喜欢这样:
/// <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)
}
例如,10.0转换为00:00:10,67.0转换为00:01:07