This documentation is archived and is not being maintained.

Generics (Visual C++)

In this section, find out how to author your own generic methods and types in Visual C++ and how to use generic types authored in C# or another language in Visual C++. This section also includes a comparison of generics and C++ templates.

Overview of Generics in Visual C++

Information about generics are, the motivation for the language feature, definitions of terms used to describe generics, and information about the use of reference types and value types as type parameters for generics.

Generic Functions

Information about defining and using generic functions and methods.

Generic Classes (Visual C++)

Information about defining and using generic classes.

Generic Interfaces (Visual C++)

Information about defining and using generic interfaces.

Generic Delegates (Visual C++)

Information about defining and using generic delegates.


Information about using constraints in generic types.

Consuming Generics from Other .NET Languages

Information about using generics defined in .NET assemblies, possibly authored in other languages, in Visual C++.

Generics and Templates

A comparison of generics and templates, when to use each, and how to combine them usefully.

How to: Iterate Over a Generic Collection with for each

Using the for each, in keyword on a generic collection.

Generics in the .NET Framework Class Library (C# Programming Guide)

Discusses .NET Framework class library's System.Collections.Generic, namespace, which includes several ready-to-use generic collection classes and associated interfaces.

Introduction to Generics (C# Programming Guide)

The generics section in the C# documentation.

Generic Types in Visual Basic (Visual Basic)

The generics section in the Visual Basic documentation.

Templates Overview

Information on templates in C++.