Managed arrays as unmanaged ptrs

  • Thread starter Thread starter The unProfessional
  • Start date Start date
T

The unProfessional

Any know how to convert a managed array to an unmanaged array (ptr)?

// Managed
float[] f = new float [6];

// Unmanaged
unsafe
{
float *pArray = f; // No good

float *pArray = (float*) f; // Compiler still doesn't allow it
}

I'm assuming there might be some marshalling involved.

Also, are unsafe {} blocks the only way to combined managed and unmanaged
logic?

Sorry... I'm still pretty new to mixing managed and unmanaged code.
 
The first declaration you have is not of a managed array. Neither in VC
2002/2003 syntax, nor in VC 2005 syntax. And an unsafe" block is not C++,
but C#.

Are you sure you are posting in the right newsgroup?

Thanks.

Ronald Laeremans
Visual C++ team
 
Sorry... It is a C# question.

Ronald Laeremans said:
The first declaration you have is not of a managed array. Neither in VC
2002/2003 syntax, nor in VC 2005 syntax. And an unsafe" block is not C++,
but C#.

Are you sure you are posting in the right newsgroup?

Thanks.

Ronald Laeremans
Visual C++ team

The unProfessional said:
Any know how to convert a managed array to an unmanaged array (ptr)?

// Managed
float[] f = new float [6];

// Unmanaged
unsafe
{
float *pArray = f; // No good

float *pArray = (float*) f; // Compiler still doesn't allow
it
}

I'm assuming there might be some marshalling involved.

Also, are unsafe {} blocks the only way to combined managed and unmanaged
logic?

Sorry... I'm still pretty new to mixing managed and unmanaged code.


--
Bill Merrill
Lead Developer
Merchant Companion
http://www.merchantcompanion.com
 
Back
Top