Understanding Generics—A Brief Word Regarding Nested Delegates

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

Understanding Generics

© 2006 Andrew Troelsen

A Brief Word Regarding Nested Delegates

I’ll wrap up this chapter by covering one final aspect regarding generic delegates. As you know, delegates may be nested within a class type to denote a tight association between the two reference types. If the nesting type is a generic, the nested delegate may leverage any type parameters in its definition:

// Nested generic delegates may access
// the type parameters of the nesting generic type.
public class MyList<T>
{
   private List<T> listOfData = new List<T>();
   public delegate void ListDelegate(T arg);
}


Previous_Page_.gif Next_Page_.gif

Personal tools