CastNETObject

CastNETObject[obj, type]
casts the specified object to a different type.

DetailsDetails

  • To use CastNETObject, you first need to load .NET/Link using Needs["NETLink`"].
  • The cast must be valid, meaning that the object must be an instance of the given class or interface type.
  • The type can be specified by a fully qualified type name or as a NETType expression.
  • There are two main situations where it is used: "upcasting" an object to call an inherited version of a method that is hidden by a version of the same method declared as "new" in a class lower in the inheritance hierarchy, or a "raw" COM object (these appear as << NETObject[System.__ComObject] >> or << NETObject[COMInterface[...]] >>) that can be successfully cast to a certain managed type
  • Calling ReleaseNETObject on an object will remove all of that object's casted references as well.
New to Mathematica? Find your learning path »
Have a question? Ask support »