How to get the list of properties of a class?

后端 未结 10 1363
陌清茗
陌清茗 2020-11-21 09:48

How do I get a list of all the properties of a class?

10条回答
  •  忘掉有多难
    2020-11-21 10:32

    Based on @MarcGravell's answer, here's a version that works in Unity C#.

    ObjectsClass foo = this;
    foreach(var prop in foo.GetType().GetProperties()) {
        Debug.Log("{0}={1}, " + prop.Name + ", " + prop.GetValue(foo, null));
    }
    

提交回复
热议问题