After changing this to
public ref struct MyType
{
................
};
MyType ^ GetMyType()
{
MyType result;
....................
return %result;
}
This code compiles without errors.
But to the best of my knowledge this involves boxing procedure. Is it
possible to avoid it in this case?
> Hi all,
>
[quoted text clipped - 18 lines]
>
> Thanks in advance
Ben Voigt - 20 Mar 2007 14:13 GMT
> After changing this to
>
[quoted text clipped - 14 lines]
> But to the best of my knowledge this involves boxing procedure. Is it
> possible to avoid it in this case?
It's a reference type, so no boxing is performed. The local variable isn't
actually on the stack, it has stack semantics (your Dispose method, if any,
will be called when the function exits even though you return the value,
which is a different flavor of the native C++ problem if you try to return a
reference to a non-static local variable).