12,982
回編集
(→概要) |
|||
488行目: | 488行目: | ||
<syntaxhighlight lang="c++"> | <syntaxhighlight lang="c++"> | ||
// C#ライブラリがタプル型の戻り値を返す場合 | // C#ライブラリがタプル型の戻り値を返す場合 | ||
struct TupleResult { | |||
int Field1; // int型 | |||
MonoString* Field2; // string型 | |||
}; | |||
MonoObject *pResult = mono_runtime_invoke(method, instance, params, &exc); | MonoObject *pResult = mono_runtime_invoke(method, instance, params, &exc); | ||
498行目: | 503行目: | ||
{ | { | ||
// タプル型から個々の値を取得 | // タプル型から個々の値を取得 | ||
TupleResult *tupleResult = static_cast<TupleResult*>(mono_object_unbox(pResult)); | |||
int intValue = tupleResult->Field1; | |||
std::string strValue = mono_string_to_utf8(tupleResult->Field2); | |||
// 結果を出力 | // 結果を出力 | ||
std::cout << "Method result: " << | std::cout << "Method result: " << intValue << ", " << strValue << std::endl; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |