mardi 3 mai 2022

How to convert class properties of single type to list of that type

Given the following class:

class MyClass {
    readonly MyType Object1 = new MyType { Prop1="Prop I want", Prop2="Prop I dont want"}
    readonly MyType Object2 = new MyType { Prop1="Prop I want", Prop2="Prop I dont want"}
    readonly MyType Object3 = new MyType { Prop1="Prop I want", Prop2="Prop I dont want"}
    readonly MyType Object4 = new MyType { Prop1="Prop I want", Prop2="Prop I dont want"}
    // etc, there are 100+ in this class, all of the type MyType
}

Is there a way I can turn this into a list of either the type MyType or the prop Prop1?

The class only contains properties of the type MyType.





Aucun commentaire:

Enregistrer un commentaire