我懒得输入对象的所有属性,所以不要这样:
myObj.property1 = value1;
myObj.property2 = value2;
myObj.property3 = value3;
myObj.property4 = value4;
myObj.property5 = value5;
...
有没有办法做到这一点?
Object myObj = new Object();
foreach (string curProperty in myCollection.AllKeys) {
var curValue = collection[curProperty];
myObj[curProperty] = curValue; // ??????????????
}