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 Operations on Objects.
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
namespace. For an example, see Create .NET Object From Constructor.
To call method
returnedValue = methodName(classObj,args,...)
The product documentation for your assembly contains information
about its classes. However, you can use the
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
reference page on the Microsoft® Developer Network. For information
about using this documentation, see To Learn More About the .NET Framework.
Objects created from .NET classes appear in MATLAB as reference
types, or handle objects. Calling the
on a .NET handle releases all references to that .NET object from MATLAB,
but does not invoke any .NET finalizers. The .NET Framework manages
For more information about managing handle objects in MATLAB, see Handle Class Destructor.