Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

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);
}

Compiler option: /clr

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.