You often need to 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 more information about objects, see MATLAB 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,...)
For more information, see:
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, see Destroying Objects.