Problems with function arguments - need help!

C

Chua Wen Ching

Okay i stuck with something.

This is more to c# rather than Directx! Just want to
clarify it first.

Right now, i am using a game engine which provide a
function to get buffer for my input.

Code:
=====

Input.GetKeyBuffer(ret_KeyData() As ENGINE_KEYDATA,
ret_DataNumber As Long) // the API

But this code works fine in VB6 and VB.NET

so i do this

ENGINE_KEYDATA[] buffer = new ENGINE_KEYDATA[255]; // An
array of 255
ENGINEInputEngine Input = new ENGINEINPUTEngine(); //
Input API for the Engine

int numberOfEvents;

Input.GetKeyBuffer(ref buffer, ref numberOfEvents);

Must ref, or else got bugs.

So i get compile errors:
================
C:\FallenDemo\Edit Box\Form1.cs(200): The best overloaded
method match for 'ENGINE._ENGINEInputEngine.GetKeyBuffer
(ref System.Array, ref int)' has some invalid arguments

C:\FallenDemo\Edit Box\Form1.cs(200): Argument '1': cannot
convert from 'ref ENGINE.ENGINE_KEYDATA' to 'ref
System.Array'

The funny part is that why is vb6 and vb.ent can compile
and see the output and not in C#?

Any help to fix this problem?

It is supposed to expect a keydata rather than
System.Array!

I know the another alternative is code my own getbuffer
using Directx... but kind of troublesome...

ENGINE is my engine name, and when i used it, i add
references to COM for that engine...

Please help!

Regards,
Chua Wen Ching :p
 
G

Grant Richins [MS]

ENGINE_KEYDATA [] buffer is semantically a specific 'sub-class' of
System.Array. You can make this work like this:

ENGINE_KEYDATA[] buffer = new ENGINE_KEYDATA[255]; // An array of 255
ENGINEInputEngine Input = new ENGINEINPUTEngine(); // Input API for the
Engine

int numberOfEvents;
System.Array arrayBuffer = buffer;

Input.GetKeyBuffer(ref arrayBuffer, ref numberOfEvents);

buffer = (ENGINE_KEYDATA[])arrayBuffer;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top