What’s wrong with my code here. Really appreciate any help. I’m trying to create a simple Scheduler class with a time object in it but I’m getting error ‘timer1’ does not exist in the current project
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)
{
}
}
}
You have the variable
defined with upper case.
Then you access it with
C# is case sensitive.