Dynamically adding properties to a dynamic object?

后端 未结 3 713
半阙折子戏
半阙折子戏 2021-01-04 12:16

i have this

dynamic d = new ExpandoObject();
d.Name = attribute.QualifiedName.Name;

so , i know that d will have a property Name. Now if i

3条回答
  •  情话喂你
    2021-01-04 13:08

    dynamic d = new ExpandoObject();
    ((IDictionary)d)["test"] = 1;
    //now you have d.test = 1
    

提交回复
热议问题