void myMethod(CLR_RT_StackFrame& stack) { int arg1, arg2; // Read arguments from the stack frame stack.SetResult_Int32(arg1 + arg2); }
void myMethod(CLR_RT_StackFrame& stack) { // Allocate an object on the managed heap MyManagedType* obj = new MyManagedType(); // Push the object onto the stack as a result stack.SetResult_Object(obj); }This example shows a method called `myMethod` that allocates an object of type `MyManagedType` on the managed heap, and then pushes a reference to the object onto the stack as the result. The CLR_RT_StackFrame class is part of the Microsoft.SPOT.Native namespace, which is included in the .NET Micro Framework SDK.