How to check if object's property is read-only.

18 次查看(过去 30 天)
Hello,
How to check if object's property is read-only or how to get the list of all the writable properties in any other way than trying to write it?

采纳的回答

Matt J
Matt J 2020-7-22
编辑:Matt J 2020-7-22
You can obtain that information from a metaclass object for the class,
In this case, it would look something like this:
>> meta=?myclass; pmeta=meta.PropertyList;
>> pmeta
pmeta =
2×1 property array with properties:
Name
Description
DetailedDescription
GetAccess
SetAccess
Dependent
Constant
Abstract
Transient
Hidden
GetObservable
SetObservable
AbortSet
NonCopyable
GetMethod
SetMethod
HasDefault
DefaultValue
Validation
DefiningClass
>> pmeta.SetAccess
ans =
'public'
ans =
'public'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Properties 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by