Using .NET classes

To use .NET classes that are defined in a specific dll we have to use a Microsoft extension to the preprocessor: the directive using.

The exception is the core library, mscorlib.dll, that requires no using directive to be available to our code. In this way we can use Console, Object, and many other basic stuff without explicit preprocessor using.

In this short example we use the class System::Uri that is defined in the System.dll:


void exp03()
System::Uri^ uri = gcnew System::Uri("");

This post is based on my reading on the book "Expert C++/CLI: .NET for Visual C++ Programmers" by Marcus Heege, APress.

No comments:

Post a Comment