[Mono-list] How to pass an object as ref or out

Robert Jordan robertj at gmx.net
Wed Apr 16 23:36:04 UTC 2014


On 16.04.2014 22:31, carmack2000 wrote:
> I use mono_object_unbox to get an object instance (Vector2) passed from C# to
> C++.
> C++
> __declspec(dllexport) void SetPosition(MonoString* ms, MonoObject* mo)
> {
> 	Vector2 pos = *(Vector2*)mono_object_unbox(mo);
> }
>
> C#
> [MethodImplAttribute(MethodImplOptions.InternalCall)]
> public static extern void SetPosition(string name, object o)
>
> If I need to pass an object as ref or out instead of value, how can I
> implement it in C++ side ?
>
> Like this sample, I want to pass object o as ref.
> C#
> [MethodImplAttribute(MethodImplOptions.InternalCall)]
> public static extern void SetPosition(string name, ref object o)

void SetPosition(MonoString* ms, MonoObject** mo)
{
}

Robert




More information about the Mono-list mailing list