467,885 Members | 1,356 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,885 developers. It's quick & easy.

Managed arrays as unmanaged ptrs

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
Nov 17 '05 #1
  • viewed: 1363
Share:
2 Replies
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" <sp**@shitbits.com> wrote in message
news:uO********************@mpowercom.net...
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

Nov 17 '05 #2
Sorry... It is a C# question.

"Ronald Laeremans [MSFT]" <ro*****@online.microsoft.com> wrote in message
news:u1*************@TK2MSFTNGP09.phx.gbl...
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" <sp**@shitbits.com> wrote in message
news:uO********************@mpowercom.net...
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


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Omid Hodjati | last post: by
4 posts views Thread by Andreas Reiff | last post: by
20 posts views Thread by =?Utf-8?B?VGhlTWFkSGF0dGVy?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.