Is it possible to eliminate the ambiguity of a conflicting type name in a usage declaration?

For example, as System.Threadingwell as System.Timersa class Timer. Therefore, if I would like to use System.Timers.Timerin a class that uses System.Threading, I need to use things like

System.Timers.Timer myTimer = new System.Timers.Timer();

every time I want to declare / initialize timers. Is there a way to tell the compiler that "when I say Timeruse System.Timers.Timerunless otherwise stated?" So i can use simple

Timer t = new Timer();

in cases by default means System.Timers.Timerunless I specify explicitly

System.Threading.Timer t2 = new System.Threading.Timer();
+5
source share
3 answers

( ). . (MSDN)

using TimersTimer = System.Timers.Timer;

....

var myTimer = new TimersTimer();
+5

.

using System.Threading;
using System.Timers;
using Timer = System.Timers.Timer;

Timer System.Timers.Timer, - .

+4

See Usage Directive

using MyAlias = System.Timers.Timer;
var foo = new MyAlias();
0
source

All Articles