I want to use System.Timers.Timer , but because this is a WinForm there's alread开发者_高级运维y System.Windows.Forms.Timer. Instead of doing System.Timers.Timer timerOne = new System.Timers.Timer();
, is there a way to do Timer timerOne = new Timer();
by forcing the use of System.Timers.Timer (or ignoring System.Windows.Forms.Timer)?
Add a using Timer = System.Timers.Timer; to the top of your source file. Note that this alias is only going to work within the file in which it's declared; you'll have to add it to each file in which you need it.
You can always alias the class name:
// Other Includes
using System.Linq;
using MyTimer = System.Timers.Timer;
MyTimer x = new MyTimer();
Another solution, but not as pretty as the others, is to create your own class and inherit it from timer.
Use the alias form of the using directive:
using Timer = System.Timers.Timer;
精彩评论