How do you Pass an array of Objects from C# to VB6 (interop)

W

Williams.sam

I am wondering if there is a way (maybe via Marshalling ) to pass an
array
of Objects of some C# defined class to VB. I am already launching a C#
form
from VB with simple call backs using a basic interface. Now what I need
is nice way to pass back an array of a certain type of class.

//Some C# class
public class SomeClass{
// various parameters (strings and ints)

}

//Code that would pass an array of the above class to the VB app....
SomeClass[] arraySomeClasses = getSomeClasses();
? passArrayToVB(arraySomeClasses);

Not really sure where to start with this one.

Many thanks and good karma in return !
 
N

Nicholas Paldino [.NET/C# MVP]

There shouldn't be much of a problem. You just make sure that in VB you
declare the function as you would normally which takes an array.

The only thing that I think you might have to do is use ref in the C#
call, since VB only allows you to declare arrays as passed by ref.

Hope this helps.
 

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