Condividi tramite


cli Namespace

The cli namespace provides language elements that do not conflict with user-defined symbols in existing source code. The cli namespace is necessary because symbols in the namespace can be used in many contexts, such that, the compiler is not able to track them as Context-Sensitive Keywords.

Remarks

When compiling with /clr, using namespace cli; is implied.

The following are symbols in the cli namespace:

It is possible to use a symbol in the cli namespace as a user-defined symbol in your code. However, once you have done so, you will have to explicitly or implicitly qualify your references to the cli language element of the same name.

// cli_namespace.cpp
// compile with: /clr
using namespace cli;
int main() {
   array<int> ^ MyArray = gcnew array<int>(100);
   int array = 0;

   array<int> ^ MyArray2 = gcnew array<int>(100);   // C2062

   // OK
   cli::array<int> ^ MyArray2 = gcnew cli::array<int>(100);
   ::array<int> ^ MyArray3 = gcnew ::array<int>(100);
}

Requirements

Compiler option: /clr

See Also

Concepts

Language Features for Targeting the CLR