班级在“快车”的“停止监视”时间上取得了一定进步。 AddTotime(h,m, s)
页: 1
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();
}
}
公平直截了当,我指的是使用阶级名称,而不是一个变数。 这里的情况
Speedrun.Go();
任何帮助都将受到高度赞赏。
www.un.org/spanish/ecosoc UPDATE!
这里发现的“CHEAP”解决办法是帮助那些可能面临类似情况的gu。
class Speedrun
{
private static Stopwatch sr = new Stopwatch();
private static int addedhours = 0;
private static int addedminutes = 0;
private static int addedseconds = 0;
public static void Go()
{
sr.Reset();
sr.Start();
addedhours = 0;
addedminutes = 0;
addedseconds = 0;
}
public static string GetTime
{
get
{
return (sr.Elapsed.Hours + addedhours) + "h " + (sr.Elapsed.Minutes + addedminutes) + "m " + (sr.Elapsed.Seconds + addedseconds) + "s";
}
}
public static void AddToTime(int hours, int minutes, int seconds)
{
addedhours = addedhours + hours;
addedminutes = addedminutes + minutes;
addedseconds = addedseconds + seconds;
}
public static void Stop()
{
sr.Stop();
}
public static void Cont()
{
sr.Start();
}
}