To get the method signature that C # sees as dynamic :
void TestMethod( [System::Runtime::CompilerServices::DynamicAttribute] System::Object^ arg ) { }
But if you just want to accept all types, you can just use System::Object^ . The attribute is misleading, as it implies semantics that are very difficult for you to provide.
To find out the actual data type, use arg->GetType() . You can then use all the power of reflection and / or DLR to detect and call elements at runtime.
It is a little more useful to use the attribute for the return type, since then C # will invoke the semantics of dynamic when using the var keyword.
[returnvalue: System::Runtime::CompilerServices::DynamicAttribute] System::Object^ TestReturn( void ) { return 1; }
source share