Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace tmp {
- public class myClass
- {
- public class InnerClass
- {
- public int I { get; set; }
- public int B { get; set; }
- }
- public string Prop1 { get; set; }
- public Test Prop2 { get; set; }
- }
- }
- }
- Type type = Type.GetType("tmp.myClass");
- object objInstance = Activator.CreateInstance(type);
- PropertyInfo[] properties = type.GetProperties();
- myClass obj = Activator.CreateInstance(type);
- properties[0].SetValue(obj,"MyString");
- Type type1 = Type.GetType("tmp.myClass");
- Type type2 = Type.GetType("tmp.myClass.InnerClass");
- var obj = Activator.CreateInstance(type1);
- var obj2 = Activator.CreateInstance(type2);
- PropertyInfo[] properties = type1.GetProperties();
- properties[1].SetValue(obj, obj2);
Add Comment
Please, Sign In to add comment