小编Jer*_*myC的帖子

为什么我的秒表没有增加时间?

该课程不会使用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)

任何帮助将不胜感激! …

.net c# static class stopwatch

0
推荐指数
1
解决办法
2423
查看次数

标签 统计

.net ×1

c# ×1

class ×1

static ×1

stopwatch ×1