For interop purpose, this is something that I always do (C#):
public static extern BigObject InteropWithCPlusPlus();
where BigObject
is ( you guess it) a big object, it's not something small like int
, or double
.
Now, is this a good practice? Or is it better to do the interop in this way:
public static extern void InteropWithCPlusPlus(ref BigObject bigObject);
I prefer the first one as it is easier to read and understand, but I afraid that it comes with performance penalty when the return object is a large, consuming memory one.