How to get a complete list of class properties including private properties.

26 ビュー (過去 30 日間)
Jaeseok
Jaeseok 2022 年 12 月 7 日
コメント済み: Steven Lord 2022 年 12 月 7 日
I wrote a class which have both public and private properties.
In a private mehod of the class, I need to get a complete list of porperties of the class, definitely, including all private properties.
Buit-in function 'properties' reveals only public properties.
What would be my options?
Thank you.

採用された回答

Steven Lord
Steven Lord 2022 年 12 月 7 日
Create a metaclass object and iterate through the PropertyList.
  2 件のコメント
Jaeseok
Jaeseok 2022 年 12 月 7 日
編集済み: Jaeseok 2022 年 12 月 7 日
very quick & absolutley correct answer. Thank you.
> mc = metaclass(MYCLASS.empty);
> prop_list = {mc.PropertyList.Name};
Steven Lord
Steven Lord 2022 年 12 月 7 日
That would work as long as MYCLASS is not Abstract. But if you have an Abstract class (meaning you can't instantiate an instance of the class) see the second and third paragraphs in the Description section on the documentation page to which I linked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by