문제

I'm working on an application that's embedding Mono, and I have a simple C# struct that is one of the parameters to one of my functions.

How do I create and pass that struct from C++ to C#?

If I have a C# struct like so:

 struct CSStruct
 {
     int mInt;
     float mFloat;
 }

Can I create a strict C++ version and pass it to mono like so?

struct CStruct
{
    int mInt;
    float mFloat;
}

// ...
CStruct var = { 10, 30.0f };
void* args[1] = { &var };
mono_runtime_invoke(method, NULL, args, NULL);
도움이 되었습니까?

해결책

Yes, that is the way it's supposed to work: value types are passed in the arguments array in mono_runtime_invoke () by taking the pointer to the value type data.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top