Mixing Managed and Unmanaged Code

I l @ ve RuBoard

Mixing managed and unmanaged code is quite simple, but it must follow some specific guidelines.

To create (or maintain) a block of unmanaged code in your programs, you need to bracket the code with the #pragma unmanaged and #pragma managed directives as needed. For example, Listing 1.4.3 shows a function in unmanaged code.

Listing 1.4.3 Using #pragma unmanaged
 #pragma unmanaged void timestwo(int* pToMultiply) {     *pToMultiply*=2; } #pragma managed 

As you can see, the timestwo function multiplies the integer pointed to by the pToMultiply pointer and is specifically implemented as unmanaged code because of the use of the #pragma unmanaged directive.

I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net