Main Content

Simplify .NET Class Names

In a MATLAB® command, you can refer to any class by its fully qualified name, which includes its namespace. A fully qualified name might be long, making commands and functions, such as constructors, cumbersome to edit and to read. You can refer to classes by the class name alone (without a namespace) if you first import the fully qualified name into MATLAB. The import function adds all classes that you import to a list called the import list. You can see what classes are on that list by typing import, without any arguments.

For example, to eliminate the need to type System. before every command in the Access a Simple .NET Class example, type:

import System.*
import System.DateTime.*

To create the object, type:

netDate = DateTime.Today;

To use a static method, type:

DaysInMonth(netDate.Year,netDate.Month)

See Also