Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中使用计时器时出错#_C#_Methods_Timer - Fatal编程技术网

C# 在C中使用计时器时出错#

C# 在C中使用计时器时出错#,c#,methods,timer,C#,Methods,Timer,我的代码有什么问题吗。非常感谢您的帮助。我试图创建一个简单的调度程序类,其中包含一个时间对象,但我发现错误是当前项目中不存在“timer1” using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Timers; namespace WindowsFormsApplication1 { class Scheduler { Timer Timer1

我的代码有什么问题吗。非常感谢您的帮助。我试图创建一个简单的调度程序类,其中包含一个时间对象,但我发现错误是当前项目中不存在“timer1”

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;

namespace WindowsFormsApplication1
{
class Scheduler
{
    Timer Timer1 = new Timer();

    public DateTime ShowCurrentTime
    {
        get
        {
            return DateTime.Now;
        }
    }

    public void Enable()
    {
        timer1.Elapsed += new ElapsedEventHandler(timer1_Elapsed);
        timer1.Interval = 5000;
        timer1.Enabled = true;
        timer1.Start();
    }

    private void timer1_Elapsed(object sender, EventArgs e)
    {

    }
}
}
你有这个变量

定时器1

用大写字母定义。 然后,您可以使用

定时器1

C#区分大小写。

您有变量

定时器1

用大写字母定义。 然后,您可以使用

定时器1


C#区分大小写。

看起来您的计时器1声明是错误的

Timer Timer1 = new Timer();

C是区分大小写的语言:)

看起来您的计时器1声明是错误的

Timer Timer1 = new Timer();

C是区分大小写的语言:)

您定义为
Timer1
,但使用的是
Timer1


C#名称区分大小写

您定义为
Timer1
,但使用的是
Timer1


C#名称区分大小写

标题和问题有什么关系?标题和身体有什么关系?哦,该死。。。我不知道这个标题。它可以改变吗?标题和问题有什么关系?标题和身体有什么关系?哦,该死的。。。我不知道这个标题。可以改变吗?哈哈。。。谢谢这是一个快速的回答!!像你这样的专家经常在这个网站上查看新问题吗?我通常每天看一次新问题。它不会出现特殊:)Lol。。。谢谢这是一个快速的回答!!像你这样的专家经常在这个网站上查看新问题吗?我通常每天看一次新问题。不会发生特殊情况:)