Generics (C++/CLI and C++/CX)

Generics are parameterized types and methods. In this section, find out which generic features are supported by both the Windows Runtime and the common language runtime, and which are supported by only the common language runtime. Also, find out how to author your own generic methods and types in C++/CLI, and how to use generic types authored in a .NET Framework language in C++/CLI. Finally, this section provides a comparison of generics and C++ templates.

In This Section

Supported by the Windows Runtime and the Common Language Runtime

Overview of Generics in C++/CLI
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 Interfaces (C++/CLI)
Information about defining and using generic interfaces.

Generic Delegates (C++/CLI)
Information about defining and using generic delegates.

Constraints on Generic Type Parameters (C++/CLI)
Information about using constraints in generic types.

Consuming Generics (C++/CLI)
Information about using generics defined in .NET assemblies, possibly authored in other languages, in C++/CLI.

Generics and Templates (C++/CLI)
A comparison of generics and templates, when to use each, and how to combine them usefully.

Supported by the Common Language Runtime

Generic Functions (C++/CLI)
Information about defining and using generic functions and methods.

Generic Classes (C++/CLI)
Information about defining and using generic classes.

How to: Iterate Over a Generic Collection with for each
Using the for each, in keyword on a generic collection.

See also

Component Extensions for .NET and UWP