我正在编写一个程序,你需要在几分钟内输入你已经骑自行车多久,然后显示你在几小时内骑了多长时间hh:mm
因此对于例如,如果用户在88分钟写的,应该显示1:28C#如何显示用户输入的整数作为时间
我找了好几个小时,现在并不能找到如何做到这一点,也许并不能帮助我总新手编码:)
//input data
Console.Write("Number of Minutes spent Cycling...");
int cycling = int.Parse(Console.ReadLine());
//perform calculations
TimeSpan cTime = TimeSpan.FromHours(cycling);
string fromTimeString = cTime.ToString("hh':'mm");
//output results
Console.WriteLine("cycling {0}", cTime);
Console.ReadLine();
}
这只是我尝试过的很多方法之一,谢谢你的帮助:)
难道你不想写“FromMinutes”吗? –
谢谢,我刚刚看到这个我的自我,这样一个愚蠢的错误 – Nathanhall