NETLink`
NETLink`
ReturnAsNETObject
ReturnAsNETObject[expr]
causes a .NET call during the evaluation of expr to return its result as an object reference (i.e. a NETObject expression), not a value.
Details and Options
- To use ReturnAsNETObject, you first need to load .NET/Link using Needs["NETLink`"].
- Most .NET objects are returned as references, but those that have a meaningful Wolfram Language representation are returned "by value", such as strings, arrays, and so-called "boxed" values like System.Int32.
- ReturnAsNETObject overrides the normal behavior and forces any object returned to the Wolfram Language to be sent only as a reference.
- ReturnAsNETObject is typically used to avoid needlessly sending large arrays of numbers back and forth between .NET and the Wolfram Language.
- You can use ReturnAsNETObject to cause only a reference to be sent; then you can use the NETObjectToExpression function at the end if the final value is needed.