// Implement the IEnumerable interface. public IEnumerator GetEnumerator() { lock (this) { // Clone the list and enumerate that so that modifications // to the trace listener list are not reflected in the // enumeration elements, as per the specification. TraceListener[] listeners = new TraceListener [list.Count]; list.CopyTo(listeners, 0); return(listeners.GetEnumerator()); } }
// Implement the IEnumerable interface. public IEnumerator GetEnumerator() { lock(this) { // Clone the list and enumerate that so that modifications // to the trace listener list are not reflected in the // enumeration elements, as per the specification. TraceListener[] listeners = new TraceListener [list.Count]; list.CopyTo(listeners, 0); return listeners.GetEnumerator(); } }