c# foreach (property in object)… Is there a simple way of doing this?

前端 未结 9 2053
感情败类
感情败类 2020-11-28 22:10

I have a class containing several properties (all are strings if it makes any difference).
I also have a list, which contains many different instances of the class.

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 22:43

    Use Reflection to do this

    SomeClass A = SomeClass(...)
    PropertyInfo[] properties = A.GetType().GetProperties();
    

提交回复
热议问题