473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Passing Byte __gc* instead of Byte __gc[]

TGF
Hello,

I am calling a Filestream::Read() (i.e. fs->Read(arg1, arg2, arg3)).
The problem is I have a pointer to an unsigned char block of memory and
would like to fill it with the call to 'Read'. However the FileStream::Read
function only takes a Byte __gc[] argument. I tried the following
Byte __gc *bytePtr = bufferPtr;

fs->Read(bytePtr, 0, 100);

....It does not allow casting from Byte __gc* to Byte __gc[]. Aren't these
them same thing? That is, aren't both memory objects on the runtime heap
as well as both being pointers (under the hood) to the base address of the
array? Any help on a solution to this would be appreciated.

-TGF


Nov 16 '05 #1
1 1466
> I am calling a Filestream::Read() (i.e. fs->Read(arg1, arg2, arg3)).
The problem is I have a pointer to an unsigned char block of memory and
would like to fill it with the call to 'Read'. However the FileStream::Read function only takes a Byte __gc[] argument. I tried the following
Byte __gc *bytePtr = bufferPtr;

fs->Read(bytePtr, 0, 100);

...It does not allow casting from Byte __gc* to Byte __gc[]. Aren't these
them same thing?
Nope, not at all.
That is, aren't both memory objects on the runtime heap
as well as both being pointers (under the hood) to the base address of the
array? Any help on a solution to this would be appreciated.


Not exactly. A __gc array has quite a lot of other information available to
the user (such as the length of the array).

In your case, it might depend on where you got bufferPtr from, but it sounds
like you're gonna have to allocate a __gc[] and then copy memory to the
other buffer :(
--
Tomas Restrepo
to****@mvps.org
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
16
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the...
2
by: Josh | last post by:
Hi All, I am trying to write a C# program to call a routine in managed C++. In the routine, the C# program passes a delegate to the managed C++. The delegate looks like this in c++: public...
6
by: jlea | last post by:
Does anyone know how to pass a managed array to a method and have that method actually create the array if necessary, ie., if the passed array is null? For example: void...
0
by: Olav Langeland | last post by:
I have a C# Form with a System.Windows.Forms.PropertyGrid(). This uses a Datagram class, implemented in both C# and C++: // C# public class Datagram { public byte _Buffer; // some code...
2
by: Edward Diener | last post by:
I need to pass a pointer to 'int' as a parameter in a managed module to a managed member function. I am assuming I need to box my value. Is this true, or can I just pass the address of my variable...
2
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
0
by: volx | last post by:
Hello all: What is the proper way to implement in MC++ a web service which accepts a multi dimensional array as a parameter to one of its methods? This does compile: double...
3
by: Smugsboy | last post by:
Hello, I would like to know the managed C++ syntax of the following method (defined in C#): void temp(out byte byteArr). I tried something like: void temp( byte byteArr __gc)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.