I have a base class like this:
public class Marker {
public int[] GetChildMarks() {
//Somehow Get Child int members
}
public int ShallNotBeInArray;
}
public class MyMarker : Marker {
public int Size, Number;
}
public class TedsMarker : Marker {
public int Power;
}
//... somewhere in main
var m = new MyMarker(){Size=3, Number = 666};
var arr = m.GetChildMarks(); // [Size, Number, Any other ints in MyMarker ]
var t = new TedsMarker() {Power=999};
var arr2 = t.GetChildMarks(); // [Power, Any other ints in TedsMarker]
So is it possible and how one can do such a thing in C# using reflection?
Aucun commentaire:
Enregistrer un commentaire