Linked Questions

Popular Questions

Debug.Listeners and Trace.Listeners are equal by reference

Asked by At

By experimenting a little with Debug and Trace classes, I came upon the fact that Debug.Listeners is referencially equivalent to Trace.Listeners.

So these happen

Console.WriteLine(Debug.Listeners == Trace.Listeners); // true
Console.WriteLine(ReferenceEquals(Debug.Listeners, Trace.Listeners)); // true

This makes impossible to log Debug and Trace messages differently.

Is this a bug, or a feature; and more importantly: why does it work like that?

Related Questions