Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Enables the use of Visual C++ keywords as identifiers.


The __identifier keyword enables the use of Visual C++ keywords as identifiers, allowing a /clr program to use identifiers that are Visual C++ reserved words from referenced metadata.

For more information, see /clr (Common Language Runtime Compilation).


Use of the __identifier keyword for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.

The __identifier keyword is valid with /clr and /clr:oldSyntax.

In the following example, a C# class (called template) is created and consumed in the Visual C++ program:

// identifier_template.cs
// compile with: /target:library
public class template {
   public void Run() { }
// keyword__identifier.cpp
// compile with: /clr
#using <identifier_template.dll>

int main() {
   __identifier(template) ^pTemplate = gcnew __identifier(template)();

Compiler option: /clr

© 2015 Microsoft