Using a .NET Object
Creating a .NET Object
You often create objects when working with .NET classes. An object is an instance of a particular class. Methods are functions that operate exclusively on objects of a class. Data types package together objects and methods so that the methods operate on objects of their own type. For information about using objects in MATLAB®, see User-Defined Classes.
You construct .NET objects in the MATLAB workspace by calling the class constructor, which has the same name as
the class. The syntax to create a .NET object
classObj = namespace.ClassName(varargin)
varargin is the list of constructor arguments to create
an instance of the class specified by
ClassName in the given
namespace. For an example, see Create .NET Object from Constructor.
To call method
returnedValue = methodName(classObj,args,...)
What Classes Are in a .NET Assembly?
The product documentation for your assembly contains information about its
classes. However, you can use the
NET.addAssembly command to
read basic information about an assembly.
For example, to view the class names of the
asm = NET.addAssembly('mscorlib'); asm.Classes
This assembly has hundreds of entries. You can open a window to the online
document for the
System namespace reference page on the
Microsoft® Developer Network. For information about using this documentation, see To Learn More About .NET.
delete Function on a .NET Object
Objects created from .NET classes appear in MATLAB as reference types, or handle objects. Calling the
delete function on a .NET handle releases all references to
that .NET object from MATLAB, but does not invoke any .NET finalizers. The .NET run-time manages
For more information about managing handle objects in MATLAB, see Handle Class Destructor.