该课程不会使用Speedrun.AddToTime(h,m,s)添加到秒表时间
不知道为什么!
class Speedrun
{
private static Stopwatch sr = new Stopwatch();
public static void Go()
{
sr.Reset();
sr.Start();
}
public static string GetTime
{
get
{
return sr.Elapsed.Hours + "h " + sr.Elapsed.Minutes + "m " + sr.Elapsed.Seconds + "s";
}
}
public static void AddToTime(int hours, int minutes, int seconds)
{
TimeSpan ts = new TimeSpan(hours, minutes, seconds);
sr.Elapsed.Add(ts);
}
public static void Stop()
{
sr.Stop();
}
public static void Cont()
{
sr.Start();
}
}
Run Code Online (Sandbox Code Playgroud)
相当简单,我使用类名本身而不是变量来引用它.如此处所见
Speedrun.Go();
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激! …