mardi 24 décembre 2019

How to set a dynamic objects array property with a list of a different dynamic object

I'm passing in 2 dynamic objects into my method. 'injuredParty' has a property called dependents that's an array of dependents that I want to fill with the second dynamic object 'dependent'

Is this possible?

public static dynamic MapTrustOnline(DetailedDto detailed, dynamic injuredParty, dynamic dependent) { 

    injuredParty.dependents = new dependent[4];

    for(int i = 0; i <= detailed.dependents.length; i++) {
        var dynDependent = new dependent();
        dynDependent.property1 = detailed.dependents[i].property1;
        dynDependent.property2 = detailed.dependents[i].property2;
        injuredParty.dependents[i] = dynDependent;
    }
}




Aucun commentaire:

Enregistrer un commentaire