I have two classes:
public class HumanProperties { int prop1; int prop2; string name;}
public class Human{int age; HumanProperties properties;}
Now if i want to create new instance of Human, i have to do Human person = new Human();
But when i try to access like person.properties.prop1=1;
then i have nullRefrence at properties, beacuse i have to make new properties too.
I have to make like that:
Human person = new Human();
person.properties = new HumanProperties();
and now i can access this person.properties.prop1=1;
This was small example, but i have huge class generated from xsd and i dont have so much time for generating manually this "person" class with all its subclasses. Is there some way how to do it programmatically or is there some generator for that?
Or can i loop through class and make for every property new class typeof property and join it to parent class?
Thanks!