Dela via


__identifier

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

__identifier(Visual_C++_keyword)

Remarks

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).

Note

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.

Example

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)();
   pTemplate->Run();
}

Requirements

Compiler option: /clr

See Also

Concepts

Language Features for Targeting the CLR