DELUXEnized
DELUXEnized

Reputation: 1278

MonoObject to c++ bool

I have embedded the mono runtime into my C++ application. The C++ code calls a C# method which returns a bool value.

How can I get the bool value from the returned MonoObject?

MonoObject* res = mono_runtime_invoke(my_method_instance, processor_, nullptr, nullptr);
bool result = *how does this work??*;

Upvotes: 1

Views: 1374

Answers (1)

DELUXEnized
DELUXEnized

Reputation: 1278

I just found the solution in the Embedded Mono documentation (http://www.mono-project.com/docs/advanced/embedding/).

int int_result = *(int*)mono_object_unbox (result);

This also works for bool values

bool value = *(bool*)mono_object_unbox(result);

Upvotes: 7

Related Questions