Solving error: 'Timer' is an ambiguous reference between 'System.Windows.Forms.Timer' and 'System.Timers.Timer'

c#

Solution

You seem to have added both `using` references (`System.Windows.Forms` and `System.Timers`). So either remove one or fully qualify the type name:

System.Timers.Timer _timer = new System.Timers.Timer(x);  

Problem

I'm trying to create a windows form application and i want to implement a Timer. ``` public void timerStart() { DateTime now = DateTime.Now; DateTime finish = base.taskEndDate; finish = finish.AddHours(_appointmentTime.Hours); //_appointmentTime is a user defined value. finish = finish.AddMinutes(_appointmentTime.Minutes); finish = finish.AddMilliseconds(_appointmentTime.Milliseconds); //Calculating the milliseconds left till task ends. int daysLeft = finish.Day - now.Day; int hoursLeft = finish.Hour - now.Hour; int minsLeft = finish.Minute - now.Minute; int secLeft = finish.Second - now.Second; int milLeft = finish.Millisecond - now.Millisecond; //Preparing to Start the timer. TimeSpan end = new TimeSpan(daysLeft, hoursLeft, minsLeft, secLeft, minsLeft); MessageBox.Show(end.ToString()); double x = end.TotalMilliseconds; System.Timers.Timer _timer = new Timer(x); } ``` Is how i have defined my method but i receive the error ``` 'Timer' is an ambiguous reference between 'System.Windows.Forms.Timer' and 'System.Timers.Timer' ``` And i am unsure how to solve the error. Once the timer ends i plan on making an event that alerts the user. I DO NOT want the timer to appear on the form.

Original source