| Contents | Index |
| On this page… |
|---|
To view property names, use the properties function.
To get and set the value of a class property, use the MATLAB dot notation:
x = ClassName.PropertyName; ClassName.PropertyName = y;
The following example gets the value of a property (the current day of the month):
obj = System.DateTime.Now; d = obj.Day;
The following example sets the value of a property (the Volume for a SpeechSynthesizer object):
NET.addAssembly('System.Speech'); obj = System.Speech.Synthesis.SpeechSynthesizer; obj.Volume = 50; Speak(obj,'You can use .NET Libraries in MATLAB');
To set a static property, you must call the NET.setStaticProperty function . For an example, see Set Static .NET Properties.
MATLAB represents public .NET fields as properties.
MATLAB represents .NET properties that take an argument as methods. For more information, see Call .NET Properties That Take an Argument.
MATLAB maps C# keywords to MATLAB property attributes, as shown in the following table.
| C# Property Keyword | MATLAB Attribute |
|---|---|
| public, static | Access = public |
| protected, private, internal | Not visible to MATLAB |
| get, set | Access = public |
| Get | GetAccess = public, SetAccess = private |
| Set | SetAccess = public, GetAccess = private |
MATLAB maps C# keywords to MATLAB field attributes, as shown in the following table.
| C# Field Keyword | MATLAB Mapping |
|---|---|
| public | Supported |
| protected, private, internal, protected internal | Not visible to MATLAB |
For more information about MATLAB properties, see Property Attributes.
![]() | Using a .NET Object | Using .NET Methods in MATLAB | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |